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.
How to Use
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:
- Trial Division: Test divisibility by primes up to the square root
- Square Root Method: Only check divisors up to √n (if no factor found, it's prime)
- Divisibility Rules: Quick checks for 2, 3, 5 eliminate many candidates
- 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
What is Prime Number Calculator?
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.
Formula
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
Examples
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