Prime Number Calculator

Check if a number is prime and find prime factorization. Uses the square root method for primality testing.

Find prime factorization of any positive integer. Shows exponential form, all divisors, and a visual factor tree.

Enter a positive integer
=
?
Max 10 trillion
Try:
help_outlineHow to Useexpand_more

Checking if a Number is Prime

This calculator determines whether a number is prime and provides complete prime factorization for composite numbers. A prime number has exactly two factors: 1 and itself.

How to Check for Primality:

  1. Trial Division: Test divisibility by primes up to the square root
  2. Square Root Method: Only check divisors up to √n (if no factor found, it's prime)
  3. Divisibility Rules: Quick checks for 2, 3, 5 eliminate many candidates
  4. 6k±1 Rule: All primes greater than 3 are of the form 6k±1

This Calculator Provides:

  • Primality determination (is it prime?)
  • Complete prime factorization with exponential form
  • Visual factor tree diagram
  • List of all divisors
infoWhat is Prime Number Calculator?expand_more

A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. In other words, a prime has exactly two divisors: 1 and itself. Numbers that have more than two divisors are called composite numbers.

The first several prime numbers are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47... Notice that 2 is the only even prime number—all other even numbers are divisible by 2.

The Fundamental Theorem of Arithmetic states that every integer greater than 1 can be expressed as a unique product of prime numbers (ignoring the order of factors). This makes primes the "building blocks" of all whole numbers.

functionsFormulaexpand_more

Square Root Method for Primality Testing:

To check if n is prime:

1. Find √n (the square root of n)

2. Check if n is divisible by any prime ≤ √n

3. If no divisor is found, n is prime

Rationale: If n = a × b and both a,b > √n, then a × b > n (contradiction)

Trial Division Steps:

1. If n ≤ 1, not prime

2. If n = 2, prime (only even prime)

3. If n is even, not prime

4. Test odd divisors from 3 to √n

5. If any divides evenly, not prime

Quick Divisibility Checks:

• Divisible by 2: Last digit is 0, 2, 4, 6, or 8

• Divisible by 3: Digit sum is divisible by 3

• Divisible by 5: Last digit is 0 or 5

lightbulbExamplesexpand_more

Example 1: Is 2 Prime?

Check divisors: 1 and 2 only

Exactly two factors found

Yes, 2 is prime (the only even prime)

Example 2: Is 17 Prime?

√17 ≈ 4.12, so check primes up to 4

17 ÷ 2 = 8.5 (not divisible)

17 ÷ 3 = 5.67 (not divisible)

No prime factor found ≤ √17

Yes, 17 is prime

Example 3: Is 51 Prime?

√51 ≈ 7.14, check primes up to 7

51 ÷ 2 = 25.5 (not divisible)

51 ÷ 3 = 17 (divisible!) ✓

No, 51 = 3 × 17 (composite)

Example 4: Prime Factorization of 84

84 ÷ 2 = 42

42 ÷ 2 = 21

21 ÷ 3 = 7

7 is prime

84 = 2² × 3 × 7

quizFAQexpand_more
What is a prime number?expand_more
A prime number is a natural number greater than 1 that has exactly two distinct divisors: 1 and itself. Examples include 2, 3, 5, 7, 11, 13. The number 1 is neither prime nor composite—it has only one divisor.
Why do we only check up to the square root?expand_more
If n = a × b where both a and b are greater than √n, then a × b would be greater than n, which is a contradiction. So at least one factor must be ≤ √n. This dramatically reduces the number of checks needed.
Is 1 a prime number?expand_more
No, 1 is not considered a prime number. By definition, prime numbers must have exactly two distinct positive divisors. The number 1 has only one divisor (itself), so it's classified as neither prime nor composite.
Why is 2 the only even prime number?expand_more
All even numbers greater than 2 are divisible by 2, meaning they have at least three factors: 1, 2, and themselves. Since primes can only have exactly two factors, 2 is the only even number that qualifies.
What is prime factorization used for?expand_more
Prime factorization is essential for finding GCF and LCM, simplifying fractions, solving problems in cryptography (RSA encryption relies on large primes), and understanding number properties in mathematics.