What Is a Prime Number?
A prime number is a whole number greater than 1 that has exactly two distinct factors: 1 and itself. The first few primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. The number 2 is the only even prime. Every other even number is divisible by 2, which immediately disqualifies them.
Numbers greater than 1 that are not prime are called composite numbers. The number 1 is neither prime nor composite. This convention was settled in the early 20th century so that the Fundamental Theorem of Arithmetic holds cleanly: every integer greater than 1 has a unique prime factorization. If 1 counted as prime, that factorization would no longer be unique, because you could multiply by 1 any number of times without changing the result.
Primes are the building blocks of all integers. The Greek mathematician Euclid proved around 300 BCE that there are infinitely many primes, which means no matter how far you search, there is always another one. For a tool that lists every factor of a number rather than just testing primality, use our Factor Calculator.
What This Calculator Does
Enter any positive integer up to one billion and this tool tells you immediately whether it is prime. If the number is composite, it shows the complete prime factorization. It also reports the digit count, the nearest prime below and above your number, and whether the input is even or odd.
- Inputs: A single positive integer (1 to 1,000,000,000)
- Outputs: Primality test, prime factorization for composites, nearest primes, digit count, and parity
For finding the greatest common factor or least common multiple of two numbers, which both rely on prime factorization, try our GCF Calculator or LCM Calculator.
How the Calculation Works
Primality Testing
The calculator uses trial division. To test whether n is prime, it checks whether any integer from 2 up to the square root of n divides n evenly. If none do, n is prime. This works because if n has a factor larger than its square root, the matching factor must be smaller than the square root, so checking up to the square root is sufficient.
The implementation skips even numbers and multiples of 3 after the initial checks, testing only numbers of the form 6k minus 1 and 6k plus 1. Every prime greater than 3 falls into one of those two forms, so this cuts the work by roughly a factor of 3 compared to testing every integer.
Prime Factorization
84 = 2 x 2 x 3 x 7 (or 2 squared x 3 x 7)
360 = 2 x 2 x 2 x 3 x 3 x 5 (or 2 cubed x 3 squared x 5)
97 = 97 (prime, no factorization needed)
For composite numbers, the calculator divides out the smallest prime factor repeatedly, then moves to the next smallest prime, until nothing remains. The result is the unique set of primes whose product equals the original number. This is the same trial division method, just extended to record which primes were used and how many times each appeared.
How to Use the Calculator
- Type any positive integer up to one billion in the input field
- The result appears instantly: prime or not prime
- If composite, review the prime factorization shown below the result
- Check the nearest primes above and below your number for context
- Use the copy button to copy the factorization or result
Example Calculations
Example 1: Testing 97
A high school student in Denver, Marcus, enters 97 to verify it on a homework problem. The calculator reports that 97 is prime. The square root of 97 is about 9.85, so the trial division only needs to test 2, 3, 5, and 7. None divide 97 evenly, confirming it is prime. The nearest prime below is 89 and the nearest above is 101. Marcus copies the result for his assignment.
Example 2: Factoring 360
An engineering student in Austin needs the prime factorization of 360 for a gear ratio problem. She enters 360 and the calculator reports it is not prime. The factorization is 2 cubed x 3 squared x 5, which means 2 x 2 x 2 x 3 x 3 x 5 = 360. This tells her that 360 has 24 factors total, which is why it divides so cleanly into many common fractions and angle measurements. A full circle has 360 degrees precisely because 360 is highly composite.
Example 3: The Trap of 91
A middle school teacher in Portland uses this calculator in class to demonstrate a common mistake. She asks students to guess whether 91 is prime. Most say yes, because it looks prime and is not divisible by 2, 3, or 5. The calculator reveals that 91 = 7 x 13, so it is composite. This is a classic example of why trial division must continue past the obvious small primes. The number 91 is one of the most frequently misidentified numbers in primality exercises.
Real-World Scenarios
Cryptography and Internet Security
Every secure connection you make online, whether to your bank, your email, or a shopping site, relies on the difficulty of factoring large composite numbers into their prime components. RSA encryption multiplies two large primes together to form a public key. The security depends on the fact that no classical computer can factor that product back into its primes in a reasonable time when the primes are large enough. A typical RSA-2048 key uses a semiprime with 617 decimal digits.
NIST released its first post-quantum cryptography standards in August 2024 (FIPS 203, 204, and 205) because quantum computers running Shor's algorithm could eventually factor these large numbers efficiently. A June 2026 White House executive order accelerated the transition timeline for federal agencies. The deadline for deprecating RSA and other quantum-vulnerable algorithms is 2035. For the exponent math that underpins these systems, see our Exponent Calculator.
Hash Tables and Computer Science
Software engineers choose prime numbers for hash table sizes to reduce collisions. When a hash table size is prime, the modulo operation distributes keys more evenly across buckets, especially when the keys follow arithmetic patterns. A database engineer at a logistics company in Memphis might use a prime like 1009 for the bucket count of a hash map tracking shipment IDs, because shipment IDs are often sequential and a non-prime bucket count would cluster them.
The Largest Known Prime
The largest known prime number as of 2026 is 2 to the 136,279,841st power minus 1, a Mersenne prime with 41,024,320 digits. It was discovered on October 12, 2024 by Luke Durant through the Great Internet Mersenne Prime Search (GIMPS) project, using cloud-based GPUs across 17 countries. This was the first Mersenne prime found using GPUs rather than ordinary CPUs. It is only the 52nd known Mersenne prime. Printing it out would require roughly 22 reams of paper.
Common Mistakes to Avoid
- Counting 1 as prime: The number 1 is neither prime nor composite. It has only one factor, while primes require exactly two. This is a convention, not a discovery, and it exists to keep prime factorization unique.
- Stopping the trial division too early: You must test every prime up to the square root, not just 2, 3, and 5. The number 91 is divisible by 7, and 221 is divisible by 13. Both look prime at first glance.
- Forgetting that 2 is prime: Two is the only even prime. Many people instinctively rule out all even numbers and accidentally exclude 2. It is also the smallest prime.
- Confusing prime with odd: Not all odd numbers are prime. The numbers 9, 15, 21, 25, 27, 33, and 35 are all odd and composite. Primality requires exactly two factors, not just being odd.
Limitations of This Calculator
This calculator handles integers up to one billion. Trial division up to the square root of one billion means at most about 31,623 trial divisions, which runs instantly in a browser. For numbers with hundreds of digits, as used in cryptography, trial division is hopeless and specialized algorithms like the Miller-Rabin primality test and the General Number Field Sieve are required. This calculator does not handle negative numbers or zero, since primality is defined only for integers greater than 1. It also does not generate lists of primes in a range; for that, a sieve-based tool would be more appropriate.
Authoritative Research & Resources
- Great Internet Mersenne Prime Search (GIMPS) - The distributed computing project that discovered the largest known prime, 2 to the 136,279,841st power minus 1, in October 2024. Running since 1996, GIMPS has discovered 18 of the largest known primes and offers a $3,000 reward for finding a new one.
- The PrimePages (University of Tennessee at Martin) - The authoritative database of the largest known primes, maintained by volunteers. It tracks all known primes with 1,000 or more digits, along with historical records, search methods, and references to the mathematical literature.
- NIST Post-Quantum Cryptography - NIST published its first three post-quantum cryptography standards in August 2024 to replace RSA, whose security depends on the difficulty of factoring large numbers into primes. The transition deadline for federal agencies is 2035.
- LibreTexts Mathematics - A peer-reviewed open-access resource covering number theory, including the Fundamental Theorem of Arithmetic, prime factorization, and applications to cryptography. College-level explanations with worked examples.