Prime Number Calculator
Check if a number is prime, find its complete prime factorisation, and list all prime numbers up to a given limit. Uses trial division and the Sieve of Eratosthenes.
Related tools
What Is a Prime Number Calculator?
A prime number calculator tests whether a number is prime and, if it is not, breaks it down into its prime factors. Prime numbers — numbers greater than 1 that are divisible only by 1 and themselves — are the fundamental building blocks of all integers. The Fundamental Theorem of Arithmetic states that every integer greater than 1 can be expressed as a unique product of primes, making prime factorisation one of the most important operations in number theory.
The calculator uses trial division for primality testing: it checks whether any integer from 2 up to the square root of the input divides evenly into it. If no divisor is found, the number is prime. For generating lists of primes, it employs the Sieve of Eratosthenes, an ancient algorithm that efficiently marks composite numbers, leaving only primes. This sieve, devised by the Greek mathematician Eratosthenes around 240 BC, remains one of the fastest methods for finding all primes below a moderate limit.
Prime numbers have enormous practical importance beyond pure mathematics. Modern internet encryption (RSA) relies on the difficulty of factoring the product of two very large primes. Hash functions, digital signatures, and secure communication protocols all depend on properties of primes. Understanding prime factorisation also underpins everyday tasks like simplifying fractions, finding LCM and HCF, and solving Diophantine equations.
How Do You Use This Prime Number Calculator?
Enter a number to check whether it is prime and to see its prime factorisation. Alternatively, enter an upper limit to generate a list of all prime numbers up to that value. Click Calculate to see the results with working shown.
- Enter a positive integer in the input field.
- Select the operation: check primality, factorise, or list primes up to N.
- Click Calculate to run the analysis.
- If checking primality, read whether the number is prime or composite.
- If factorising, review the step-by-step division showing each prime factor extracted.
- If listing primes, scroll through the generated list up to your specified limit.
How Does the Prime Number Calculator Formula Work?
The formula used: A prime has exactly 2 factors: 1 and itself. Trial division checks divisibility up to √n. Fundamental theorem: every integer > 1 has a unique prime factorisation.
A prime number has exactly two distinct positive divisors: 1 and itself. The number 1 is not considered prime. To test primality by trial division, check divisibility by every integer from 2 up to the square root of n.
If no integer d (where 2 ≤ d ≤ √n) divides n evenly, then n is prime.
For prime factorisation, repeatedly divide the number by the smallest prime factor available. Start with 2, then try 3, 5, 7, and so on until the quotient is 1. The Sieve of Eratosthenes generates all primes up to a limit N by starting with a list of integers from 2 to N, then iteratively marking multiples of each prime as composite. The unmarked numbers remaining are all primes up to N.
What Are Some Example Calculations?
Is 84 prime? 84 ÷ 2 = 42, 42 ÷ 2 = 21, 21 ÷ 3 = 7. So 84 = 2² × 3 × 7. Not prime. Is 97 prime? No factor up to √97 ≈ 9.85 divides 97. Yes, 97 is prime.
Determine whether 97 is prime
√97 ≈ 9.85. Test divisors 2, 3, 5, 7. 97/2 = 48.5, 97/3 = 32.33, 97/5 = 19.4, 97/7 = 13.86. None divide evenly.
97 is prime. It has no factors other than 1 and 97.
Find the prime factorisation of 360
360 ÷ 2 = 180. 180 ÷ 2 = 90. 90 ÷ 2 = 45. 45 ÷ 3 = 15. 15 ÷ 3 = 5. 5 ÷ 5 = 1.
360 = 2³ × 3² × 5.
List all primes up to 50 using the Sieve of Eratosthenes
Start with 2–50. Mark multiples of 2, then 3, then 5, then 7 (7² = 49 < 50). Remaining unmarked numbers are primes.
Primes up to 50: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 (15 primes).
When Should You Use a Prime Number Calculator?
Use the prime number calculator when you need to determine if a number is prime, break a number into its prime factors, or generate a list of primes. Students use it for number theory homework, simplifying fractions (by finding common prime factors), and computing LCM and HCF. Programmers use it for hashing algorithms, random number generation, and cryptographic key generation.
Prime factorisation is also the foundation for solving many mathematical problems. Determining the number of divisors a number has requires its prime factorisation. Checking whether a number is a perfect square requires all prime exponents to be even. Finding the LCM and HCF of multiple numbers is straightforward once each is factorised. If you are working with number theory, algebra, or any application involving divisibility, this calculator provides the essential data.
What Do These Terms Mean?
What Are the Best Tips to Know?
- You only need to test divisors up to √n for primality — if no factor is found by then, the number is prime.
- The only even prime number is 2. All other even numbers are divisible by 2 and therefore composite.
- Use the prime factorisation to count total divisors: if n = p₁^a × p₂^b × ..., the number of divisors is (a+1)(b+1)....
- A number is a perfect square if and only if all exponents in its prime factorisation are even.
- Memorise the primes under 100 for faster mental calculations: 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.
What Mistakes Should You Avoid?
- Thinking 1 is prime — by definition, a prime must have exactly two distinct factors. The number 1 has only one factor (itself).
- Forgetting that 2 is the only even prime — students often skip 2 when listing primes or assume all primes are odd.
- Testing divisors beyond √n, which wastes time — if n has a factor larger than √n, it must also have one smaller than √n.
- Confusing 'prime' with 'odd' — 9, 15, 21, and 25 are all odd but not prime.
Frequently Asked Questions
Is 1 a prime number?
No. By modern mathematical convention, a prime number must have exactly two distinct positive divisors. The number 1 has only one divisor (itself), so it is neither prime nor composite.
Why is 2 the only even prime?
Every even number greater than 2 is divisible by 2, so it has at least three divisors (1, 2, and itself). Only 2 is even and has exactly two divisors.
How does the Sieve of Eratosthenes work?
Write all integers from 2 to N. Starting with 2, mark all its multiples as composite. Move to the next unmarked number (3), mark its multiples. Continue until you reach √N. All remaining unmarked numbers are prime.
What is the largest known prime number?
The largest known primes are Mersenne primes of the form 2ᵖ − 1. As of 2024, the largest known prime is 2^136,279,841 − 1, discovered by the Great Internet Mersenne Prime Search (GIMPS).
Why are prime numbers important in cryptography?
RSA encryption relies on the fact that multiplying two large primes is easy, but factoring the product back into those primes is extremely difficult. This asymmetry secures online banking, emails, and digital signatures.
How many prime numbers are there?
Infinitely many. Euclid proved around 300 BC that there is no largest prime. For any finite list of primes, you can always construct a number that reveals a new prime not in the list.
What is the prime factorisation of a prime number?
A prime number's factorisation is just itself. For example, the prime factorisation of 13 is simply 13. It cannot be broken down further.
More Maths & Conversion Calculators
Category
← Maths & Conversion CalculatorsNext up
Fraction Calculator →