Calcoid
Math

Prime Number Calculator

Check if a number is prime, show its prime factorization, all divisors, and the next/previous prime.

Check a number

Up to 1 trillion is supported.

Is 997 prime?

Yes, prime

Neighbors

Previous prime: 991. Next prime: 1009.

All divisors (2)

1, 997

Frequently Asked Questions about the Prime Number Calculator

What is a prime number?
A prime is a whole number greater than 1 that has no positive divisors other than 1 and itself. The first ten primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. Every integer greater than 1 that is not prime is called composite.
Is 1 a prime number?
No. By modern mathematical convention, 1 is neither prime nor composite. Excluding it keeps the fundamental theorem of arithmetic clean: every integer greater than 1 has a unique prime factorization, and that uniqueness breaks down if 1 counts as prime.
How does the calculator check primality?
It uses trial division with a 6k +/- 1 optimization, testing candidate divisors up to the square root of n. All integers above 3 that are divisible by 2 or 3 are eliminated first, then only values of the form 6k - 1 and 6k + 1 are tested. The calculator accepts integers up to 1,000,000,000,000 (one trillion).
What is prime factorization?
Prime factorization is writing a composite number as a product of primes. For example, 60 = 2 x 2 x 3 x 5. The fundamental theorem of arithmetic guarantees this factorization is unique for every integer greater than 1, which is the mathematical foundation behind RSA encryption.
Are there infinitely many primes?
Yes. Euclid proved this around 300 BCE with a short argument by contradiction: assume a finite list of all primes, multiply them together and add 1, and the result is divisible by none of them, requiring a new prime. Despite their infinite count, primes thin out as numbers grow: near a number n, the fraction of integers that are prime is roughly 1 / ln(n).