๐Ÿ” Prime Number Calculator

Check if a number is prime or composite.

Calculate Now

What is a Prime Number Calculator?

A Prime Number Calculator instantly tells you whether a whole number is prime (divisible only by 1 and itself) or composite (has other factors). It's handy for students learning number theory, for competitive exam prep โ€” SSC, banking, and other Indian government exams often include prime-factorization questions โ€” and for programmers who want to sanity-check a number before writing their own prime-checking logic.

How It Works

The calculator uses trial division: it checks whether the number is divisible by any integer from 2 up to its square root. If no divisor is found, the number is prime. Testing only up to โˆšn instead of all the way to n is what makes this fast, since any factor larger than โˆšn must pair with a factor smaller than โˆšn.

For number n:
For i = 2 to โˆšn:
  if n % i == 0 โ†’ composite (not prime)
If no i divides n evenly โ†’ prime

Worked Example

Check whether 97 is prime:

โˆš97 โ‰ˆ 9.849, so we only need to test i = 2 through 9
97 รท 2, 3, 4, 5, 6, 7, 8, 9 โ€” none divide evenly
Result: 97 is Prime โœ“

Now compare with 91: โˆš91 โ‰ˆ 9.54, and at i = 7 we find 91 รท 7 = 13 exactly โ€” so 91 is composite (7 ร— 13), even though at a glance it can look prime.

How to Use This Calculator

  1. Enter any whole number 2 or greater.
  2. Click Calculate.
  3. The result shows โœ“ Prime or โœ— Not Prime instantly.

Things to Know

  • 2 is the only even prime number โ€” every other even number is divisible by 2.
  • 1 is neither prime nor composite by mathematical definition.
  • There are 25 prime numbers below 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.
  • For very large numbers, trial division becomes slow โ€” cryptographic systems instead use probabilistic tests like Miller-Rabin.

Pair this with our LCM & GCD Calculator to explore factorization further, or try the Square Root Calculator used in the trial-division method above.

More Worked Examples

Checking a three-digit number: Is 221 prime? โˆš221 โ‰ˆ 14.87, so we test divisors 2 through 14. It fails at 2, 3, 5, 7, 11, and 13, but at i=13: 221 รท 13 = 17 exactly โ€” so 221 = 13 ร— 17 is composite. This is a classic "trap" number in exams because it looks similar to nearby primes like 223, and only careful division to 13 reveals the factor.

Checking a number that just misses a small factor: Is 149 prime? โˆš149 โ‰ˆ 12.2, so testing i = 2 through 12: none divide evenly (149 is odd, not divisible by 3 since 1+4+9=14, not by 7 since 149รท7โ‰ˆ21.3, not by 11 since 149รท11โ‰ˆ13.5). So 149 is prime โ€” a good example of why every candidate divisor up to the square root must actually be checked rather than assumed.

Prime Factorization: Breaking a Composite Number Down Fully

Once this calculator tells you a number is composite, the natural next step is often finding its complete prime factorization โ€” expressing it as a product of primes only. For 360, repeatedly dividing by the smallest possible prime gives 360 = 2ร—180 = 2ร—2ร—90 = 2ร—2ร—2ร—45 = 2ร—2ร—2ร—3ร—15 = 2ร—2ร—2ร—3ร—3ร—5, or compactly 2ยณ ร— 3ยฒ ร— 5. Every composite number has exactly one such prime factorization (the Fundamental Theorem of Arithmetic), which is why prime factorization underlies both the LCM & GCD Calculator's prime-factorization method and RSA cryptography's reliance on the difficulty of reversing this process for very large numbers.

Who Uses Prime Number Checks?

Prime numbers sit at the foundation of several fields well beyond the classroom. Computer science students and working engineers rely on primes for cryptography โ€” RSA encryption, which secures everything from banking transactions to HTTPS websites, depends on the fact that multiplying two large primes together is easy, but factoring that product back into its original primes is extremely hard. Students preparing for Indian competitive exams such as SSC CGL, bank PO, and railway recruitment exams frequently face prime-factorization and divisibility questions where a quick prime check settles the answer. Programmers learning algorithms use prime checking as a classic beginner exercise in optimizing loops (testing only up to โˆšn rather than n). Teachers use it to build number-theory lessons around patterns in the primes, and puzzle enthusiasts sometimes use prime properties to reason through number-placement logic.

Frequently Asked Questions

Q: Why does the calculator only test divisors up to the square root of the number?
A: If a number n has a factor larger than โˆšn, it must be paired with a corresponding factor smaller than โˆšn (since factors multiply to give n). This means checking all integers up to โˆšn is enough to catch every possible factor pair โ€” checking beyond that point would only find duplicate information, wasting time on large numbers.

Q: Is 1 a prime number?
A: No. By mathematical definition, a prime number must have exactly two distinct positive divisors: 1 and itself. Since 1 only has one divisor (itself), it's classified as neither prime nor composite โ€” a special case many people get wrong.

Q: Why is 2 the only even prime number?
A: Every even number greater than 2 is divisible by 2 in addition to 1 and itself, which by definition makes it composite, not prime. 2 is the sole exception because it's the smallest even number and has no divisors besides 1 and 2.

Q: How many prime numbers are there below 100, and can you list them?
A: There are exactly 25 primes below 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, and 97. Memorizing this list is a common shortcut for competitive exam prep since prime-factorization questions frequently reuse these same numbers.

Q: Why does trial division become impractical for very large numbers, like those used in encryption?
A: Trial division's runtime grows with โˆšn, so for a 300-digit number used in real-world cryptography, checking every possible divisor up to its square root would take longer than the age of the universe on current computers. This is exactly why cryptographic systems rely on probabilistic primality tests like Miller-Rabin rather than simple trial division for numbers at that scale.

📅 Last reviewed: July 2026 · Formulas verified against RBI/SEBI/IT Dept guidelines.