Checks any number between 1 and 10^12 and returns its status as prime or composite, along with all its divisors and associated data, as well as optional detailed explanations and prime types!

GET   is-this-number-prime (free)

http://api.prime-numbers.io/is-this-number-prime.php?key=YOUR_API_KEY&number=<number>&include_explanations=<boolean>&include_prime_types_list=<boolean>&language=<string>
AUTHORIZATION API Key

This request is using the API Key from Prime Numbers API collection in thePime Numbers API environment

PARAMS


key
YOUR_API_KEY

(Required) your API key

number
<number>

(Required) enter a number to check if it is prime or composite (between 1 and 10^12).

include_explanations
<boolean>

includes the full explanations for each item if true (default is false)

include_prime_types_list
<boolean>

includes the full prime types list for each item if true (default is false)

language
<string>

show the output translated into that language (it can be english, mandarin, hindi, spanish, french, german, italian, japanese, russian) (default is english)


Success (check prime number)


Example Request
curl --location --request GET 'http://api.prime-numbers.io/is-this-number-prime.php?key=YOUR_API_KEY&number=41&language=english'
                                    
Example Response

200 OK


{
    "target_number": 41,
    "is_prime": "true",
    "all_divisors": "1 41 ",
    "base_conversions": {
        "binary_value": "101001",
        "senary_value": "105",
        "hexa_value": "29"
    },
    "previous_prime_gap": 4,
    "prime_density": "7.86960000",
    "isolated_primes": {
        "is_isolated_prime": "false",
        "isolated_prime_density": "7.86960000"
    },
    "birth_certificate": "2018-06-16 22:01:25: server mac-server processed 6 computations in 0.00026679684322637 micro-seconds using 2 x 3 GHz Quad-Core Intel Xeon CPUs"
}
    


Success (check composite number)


Example Request
curl --location --request GET 'http://api.prime-numbers.io/is-this-number-prime.php?key=YOUR_API_KEY&number=99909999&language=english'
                                    
Example Response

200 OK


{
    "target_number": 99909999,
    "is_prime": "false",
    "all_divisors": "1 3 7 9 19 21 23 57 63 69 133 161 171 191 207 361 399 437 483 573 1083 1197 1311 1337 1449 1719 2527 3059 3249 3629 3933 4011 4393 7581 8303 9177 10887 12033 13179 22743 24909 25403 27531 30751 32661 39537 58121 68951 74727 76209 83467 92253 174363 206853 228627 250401 276759 482657 523089 584269 620559 751203 1447971 1585873 1752807 4343913 4757619 5258421 11101111 14272857 33303333 99909999 "
}
    


Success (with explanations and prime_types)


Example Request
curl --location --request GET 'http://api.prime-numbers.io/is-this-number-prime.php?key=YOUR_API_KEY&number=60309232769&include_explanations=true&include_prime_types_list=true&language=english'
                                    
Example Response

200 OK


{
    "target_number": 60309232769,
    "is_prime": "true",
    "all_divisors": "the list of divisors is only available for numbers < 10^8",
    "base_conversions": {
        "binary_value": "111000001010101101011101110010000001",
        "binary_value_explanation": "prime number base-2 (binary value), useful for cryptography and cryptocurrency",
        "senary_value": "43412232054545",
        "senary_value_explanation": "prime number base-6 (senary value), useful for mathematical research",
        "hexa_value": "e0ab5dc81",
        "hexa_value_explanation": "prime number base-16 (hexa value), useful for cryptography and cryptocurrency"
    },
    "previous_prime_gap": 118,
    "previous_prime_gap_explanation": "how many successive prime and composite numbers are between this prime and the previous one",
    "prime_density": "4.04110000",
    "prime_density_explanation": "how many prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)",
    "isolated_primes": {
        "is_isolated_prime": "true",
        "is_isolated_prime_explanation": "prime numbers that are more than 100 composite numbers away from each of their neighbours, with an average density of 0.008086097174%",
        "combined_gap": 220,
        "previous_prime_gap": 118,
        "next_prime_gap": 102,
        "isolated_prime_density": "4.04110000",
        "isolated_prime_density_explanation": "how many chances (%) to randomly find an isolated prime number in this million composite numbers (between 60 309 000 000 and 60 310 000 000)"
    },
    "prime_types": {
        "is_palindrome": "false",
        "palindrome_explanation": "number that is simultaneously palindromic (which reads the same backwards as forwards) and prime (examples: 2, 3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929) (reference: https://en.wikipedia.org/wiki/Palindromic_prime)",
        "palindrome_percentage": "0.00000000",
        "palindrome_density_explanation": "how many palindrome prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)",
        "is_twin": "false",
        "twin_explanation": "primes that are no more than 2 composite numbers from each other (examples: (3, 5), (5, 7), (11, 13), (17, 19)) (reference: https://en.wikipedia.org/wiki/Twin_prime)",
        "twin_percentage": "0.43360000",
        "twin_density_explanation": "how many twin prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)",
        "is_cousin": "false",
        "cousin_explanation": "primes that are no more than 4 composite numbers from each other (examples: (3, 7), (7, 11), (13, 17), (19, 23), (37, 41), (43, 47)) (reference: https://en.wikipedia.org/wiki/Cousin_prime)",
        "cousin_percentage": "0.43060000",
        "cousin_density_explanation": "how many cousin prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)",
        "is_sexy": "false",
        "sexy_explanation": "primes that are no more than 6 composite numbers from each other (examples: (5,11), (7,13), (11,17), (13,19), (17,23), (23,29)) (reference: https://en.wikipedia.org/wiki/Sexy_prime)",
        "sexy_percentage": "0.77450000",
        "sexy_density_explanation": "how many sexy prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)",
        "is_reversible": "false",
        "reversible_explanation": "primes that become a different prime when their decimal digits are reversed. The name emirp is obtained by reversing the word prime (examples: 13, 17, 31, 37, 71, 73, 79, 97, 107, 113, 149, 157) (reference: https://en.wikipedia.org/wiki/Emirp)",
        "reversible_percentage": "0.00000000",
        "reversible_density_explanation": "how many reversible prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)",
        "is_pandigital": "false",
        "pandigital_explanation": "pandigital prime in a base has at least one instance of each base digit. (examples: 2143 (base 4), 7654321 (base 7)) (reference: https://www.xarg.org/puzzle/project-euler/problem-41/)",
        "pandigital_percentage": "0.00000000",
        "pandigital_density_explanation": "how many pandigital prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)",
        "is_repunit": "false",
        "repunit_explanation": "repunits primes are positive integers in which every digit is one (examples: 11, 1111111111111111111) (reference: https://primes.utm.edu/glossary/page.php?sort=Repunit)",
        "repunit_percentage": "0.00000000",
        "repunit_density_explanation": "how many repunit prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)",
        "is_mersenne": "false",
        "mersenne_explanation": "mersenne prime is a prime number that is of the form 2n - 1 (one less than a power of two) for some integer n. They are named after Marin Mersenne (1588-1648), a French monk who studied them in his Cogitata Physica-Mathematica (1644) (examples: 3 (2^2 - 1), 7 (2^3 - 1), 31 (2^5 - 1) ) (reference: https://www.mersenne.org/)",
        "mersenne_percentage": "0.00000000",
        "mersenne_density_explanation": "how many mersenne prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)",
        "is_fibonacci": "false",
        "fibonacci_explanation": "prime numbers that are also Fibonacci numbers (examples: 2, 3, 5, 13, 89, 233, 1597) (reference: https://oeis.org/A005478)",
        "fibonacci_percentage": "0.00000000",
        "fibonacci_density_explanation": "how many fibonacci prime numbers (%) can be found in this million composite numbers (between 60 309 000 000 and 60 310 000 000)"
    },
    "birth_certificate": "2020-07-23 19:33:12: server ferdinand processed 245 579 computations in 6.9846240559611 micro-seconds using 2 x 2.93GHz Hexa-Core Intel Xeon CPUs",
    "birth_certificate_explanation": "how many computations, how much time and what computer power was used to find this prime number"
}
    


Error (no key)


Example Request
curl --location --request GET 'http://api.prime-numbers.io/is-this-number-prime.php?key=&language=english'
                                    
Example Response

403 Forbidden


{
    "error": "please include the api key in your query"
}
    


Error (no number)


Example Request
curl --location --request GET 'http://api.prime-numbers.io/is-this-number-prime.php?key=YOUR_API_KEY&number=&language=english'
                                    
Example Response

404 Not Found


{
    "error": "please include the number you want to check"
}
    


Error (alpha number)


Example Request
curl --location --request GET 'http://api.prime-numbers.io/is-this-number-prime.php?key=YOUR_API_KEY&number=a&language=english'
                                    
Example Response

404 Not Found


{
    "error": "the number you want to check has to be an integer"
}
    


Error (prime number too big)


Example Request
curl --location --request GET 'http://api.prime-numbers.io/is-this-number-prime.php?key=YOUR_API_KEY&number=9000000000071&language=english'
                                    
Example Response

404 Not Found


{
    "error": "the number you want to check has to be < 10^12"
}
    


Error (prime number no divisors over 100 mil.)


Example Request
curl --location --request GET 'http://api.prime-numbers.io/is-this-number-prime.php?key=YOUR_API_KEY&number=100000001&language=english'
                                    
Example Response

200 OK


{
    "target_number": 100000001,
    "is_prime": "false",
    "all_divisors": "the list of divisors is only available for numbers < 10^8"
}