Prime Number Calculator
Whether a number is prime, its prime factorisation, how many divisors it has, and the nearest primes either side, for numbers up to a trillion.
Result
This number is: Composite, not prime
Up to 1,000,000,000,000 so the check stays instant.
- Prime factorisation
- 2^3 × 3^2 × 5
- Number of divisors
- 24
- All divisors
- 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, 60, 72, 90, 120, 180, 360
- Nearest prime below
- 359
- Nearest prime above
- 367
https://calcgallery.com/algebra-numbers/prime-number-calculator/
Results follow the mathematical operation and values shown. Check that you selected the intended operation, convention and dataset type before relying on the result. Read the full disclaimer
How to use the Prime Number Calculator
- Enter a whole number from 1 up to a trillion.
- Read whether it is prime, its prime factorisation, and how many divisors it has.
- See every divisor when there are 64 or fewer, and the nearest primes on either side.
How it works
To test n, the page divides by 2 and then by every odd number up to √n. If none divides it, n is prime: any factor larger than √n would pair with one smaller, which would already have been found. Each factor found is divided out repeatedly, which gives the prime factorisation as it goes.
Every whole number is a product of primes
The fundamental theorem of arithmetic says every whole number above 1 can be written as a product of primes in exactly one way, apart from order. That factorisation is the starting point for greatest common factors, least common multiples and simplifying fractions and roots.
With your numbers
- 360 = 2^3 × 3^2 × 5
Quick reference
Up to 1,000,000,000,000 so the check stays instant.
| Example | This number is |
|---|---|
| 360 | Composite, not prime |
| 97 | Prime |
| 1 | Neither prime nor composite |
| 2 | Prime |
| 561 | Composite, not prime |
| 999,999,999,989 | Prime |
Common questions about the Prime Number Calculator
- Is 1 a prime number?
- No, and it is not composite either. A prime has exactly two divisors, 1 and itself; 1 has only one. Excluding 1 is what makes every number's prime factorisation unique: otherwise 6 could be 2 × 3, or 1 × 2 × 3, or 1 × 1 × 2 × 3.
- How is the number of divisors worked out?
- From the exponents in the factorisation. 360 = 2³ × 3² × 5, and each divisor picks a power of 2 from 0 to 3, of 3 from 0 to 2, and of 5 from 0 to 1: 4 × 3 × 2 = 24 divisors. The page lists them to confirm.
- What is special about 561?
- It is the smallest Carmichael number: it fools a common shortcut test for primes, Fermat's test, into saying it is prime. It is really 3 × 11 × 17. This page divides by every candidate up to the square root, so it cannot be fooled.
- Why is there an upper limit?
- Checking a number by trial division takes up to its square root in steps. At a trillion that is a million steps, which is instant; far above it, the page would hang your browser.