Prime Factorization Calculator
Prime factors with division steps, a factor tree, the divisor count and every divisor.
Number theory is the study of whole numbers: primes, divisibility and remainders. These free calculators factor numbers into primes, test primality, find the GCD and LCM, work out a mod n and modular inverses, and convert between binary, octal, decimal and hex, showing every step with exact arithmetic.
One number for its prime factors, divisors and φ(n); two to 10 numbers, separated by commas or spaces, for the GCD and LCM. Up to 40 digits each.
Steps: Division steps and every divisor · Primality test and nearest primes. For a mod n, modular powers and inverses, use the modulo calculator.
Prime factors with division steps, a factor tree, the divisor count and every divisor.
Is it prime? Proof by smallest factor, next and previous primes, and a primes list for any range.
LCM and GCF of up to 10 numbers with steps: multiples, prime factors, Euclid’s algorithm and a coprime check.
a mod n with steps, negative numbers, power mod and modular inverses.
Decimal to binary with each division by 2, padding to 8–64 bits, two’s complement and fractions.
Binary to decimal with each bit’s power of 2 and a running total, signed or unsigned, fractions included.
Hex to decimal with place-value steps, plus binary, octal and any base 2 to 36, fractions included.
Binary addition, subtraction and bitwise operations with steps, at 8 to 64 bits, signed or unsigned.
Exact n! with steps and every digit, plus digit count, trailing zeros, n!! and Stirling’s approximation.
Find your task in the first column. Each Try link opens the calculator with that example already filled in, and the result column shows what it returns.
| Task | Example | Result | Calculator |
|---|---|---|---|
| Break a number into prime factors; list its divisors | 360 Try this factorization | , 24 divisors | Prime factorization calculator |
| Test whether a number is prime | Is 221 prime? Try this check | Composite: 221 = 13 × 17 | Prime number checker |
| Euler’s totient φ(n) | φ(360) Try this totient | 96 | Prime factorization calculator |
| Greatest common divisor and least common multiple | 252 and 198 Try this GCD | GCD 18, LCM 2772 | GCD and LCM calculator |
| Remainder of a division, including negative numbers | −17 mod 5 Try this remainder | 3 (but −2 in C, Java and JavaScript) | Modulo calculator |
| Modular power for a huge exponent | Try this power | 9 | Modulo calculator |
| Modular inverse (as in RSA keys) | Try this inverse | 2753 | Modulo calculator |
| Decimal to binary, with every division by 2 | −5 as a signed byte Try this conversion | 1111 1011 (two’s complement) | Decimal to binary converter |
| Binary to decimal, with each bit’s place value | 1111 1011 Try this conversion | 251 unsigned, −5 as a signed byte | Binary to decimal converter |
| Convert between bases 2 to 36, fractions included | Hex 1A3F to decimal Try this conversion | 6719 | Number base converter |
| Binary arithmetic, bitwise AND, OR, XOR, shifts | 127 + 1 as a signed 8-bit number Try this sum | −128, with an overflow warning | Binary calculator |
| Exact factorial with every digit | 100! Try this factorial | 158 digits, 24 trailing zeros | Factorial calculator |
The prime number checker and the prime factorization calculator overlap. Use the checker for a yes or no answer on numbers up to 200 digits, with the nearest primes on either side. Use the factorization calculator, for numbers up to 40 digits, when you need every prime factor, the divisors, the divisor sum or φ(n).
Number theory is the branch of mathematics that studies the whole numbers and the relationships between them: which numbers divide which, how every number breaks into primes, and what remainders are left after division. Its central objects are prime numbers, divisibility, the greatest common divisor and modular arithmetic, the arithmetic of remainders.
Its foundation is the fundamental theorem of arithmetic: every whole number greater than 1 is a product of primes in exactly one way, apart from the order of the factors. That is why 360 is always , whichever factor you divide out first, and it is why the primes are often called the building blocks of the integers.
The subject is old. Euclid proved around 300 BC that there are infinitely many primes and described the GCD algorithm still used today. Pierre de Fermat, often called the father of modern number theory, posed many of its classic problems in the 1600s, and Carl Friedrich Gauss is credited with calling number theory “the queen of mathematics”.
Is number theory hard? The basic ideas, such as primes, divisibility and remainders, need nothing beyond school arithmetic. University courses become harder because they ask you to prove results rather than compute them. Working small cases by hand and checking each one with a calculator is a good way to build intuition before attempting proofs.
These are the methods the calculators follow for each example. Use the link under each answer to open the same problem, then change the numbers to your own.
Divide by 2 while you can
360 ÷ 2 = 180, 180 ÷ 2 = 90, 90 ÷ 2 = 45. 45 is odd, so 2 appears three times.
Move on to 3
45 ÷ 3 = 15 and 15 ÷ 3 = 5, so 3 appears twice.
Stop at a prime
5 is prime, so the division ends there.
Count the divisors
Add 1 to each exponent and multiply: (3 + 1)(2 + 1)(1 + 1) = 24 divisors.
Find how far to test
If 221 has a factor, one of them is at most , so only the primes 2, 3, 5, 7, 11 and 13 need testing.
Rule out the small primes
221 is odd, its digits add up to 5 (not a multiple of 3), it does not end in 0 or 5, and dividing by 7 or 11 leaves a remainder.
Try 13
221 ÷ 13 = 17 exactly.
Divide the larger by the smaller
252 = 1 × 198 + 54.
Repeat with the divisor and the remainder
198 = 3 × 54 + 36, then 54 = 1 × 36 + 18, then 36 = 2 × 18 + 0.
Read off the GCD
The last non-zero remainder is 18, so gcd(252, 198) = 18.
Find the LCM
.
Check the conditions for Fermat’s little theorem
13 is prime and does not divide 3, so .
Reduce the exponent
200 = 16 × 12 + 8, so .
Finish with small numbers
, and .
Convert the whole part
Divide 156 by 2 repeatedly and keep the remainders: 0, 0, 1, 1, 1, 0, 0, 1. Read them from the bottom up: 10011100.
Convert the fraction
Multiply 0.625 by 2 repeatedly and keep the whole parts: 1.25 → 1, 0.5 → 0, 1.0 → 1. Read them from the top down: .101.
Join the two parts
Check: 128 + 16 + 8 + 4 + 0.5 + 0.125 = 156.625.
| Formula | Rule | Example |
|---|---|---|
| Division with remainder | , with | 125 = 7 × 17 + 6, so 125 mod 7 = 6 |
| Euclid’s algorithm | gcd(252, 198) = gcd(198, 54) = … = 18 | |
| GCD and LCM | 18 × 2772 = 252 × 198 = 49,896 | |
| Number of divisors | For : | τ(360) = 4 × 3 × 2 = 24 |
| Euler’s totient | φ(360) = 360 × ½ × ⅔ × ⅘ = 96 | |
| Fermat’s little theorem | for a prime p that does not divide a | |
| Modular inverse | x with ; it exists exactly when gcd(a, n) = 1 | 17 × 2753 = 46,801 ≡ 1 (mod 3120) |
| Trailing zeros of n! | 100! ends in 20 + 4 = 24 zeros |
There is no Chinese remainder theorem solver, no linear Diophantine equation solver and no continued fractions tool yet, and no Legendre or Jacobi symbols, discrete logarithms or prime list generator. The GCD calculator’s Bézout coefficients give one solution of ax + by = gcd(a, b), which is the starting point for a linear Diophantine equation. Prime factorization stops after about one second on a number whose prime factors are all very large, and says so instead of guessing. For how to type numbers in other bases and use bitwise operators, see the number bases and bitwise operations manual page, and for how results are tested, see the methodology.
Every tool here works with exact whole numbers stored digit by digit, not the 15 to 17 significant digits of an ordinary calculator. The factorial calculator prints all 158 digits of 100!, and the modulo calculator handles numbers of up to 100 digits with exponents of up to 30 digits.
Writing code? The binary calculator handles two’s complement, overflow and bit shifts at a word size of 8, 16, 32 or 64 bits, the decimal to binary converter shows every division by 2, the binary to decimal converter shows the place value of every bit, and the number base converter turns hex such as FF into decimal 255. Watch negative remainders: −17 % 5 is −2 in C, Java and JavaScript but 3 in Python, and the modulo calculator shows both.
All of these number theory calculators are free, need no account and run in your browser, with every step shown and nothing locked. Results are checked against reference values by automated tests, as described in how we verify calculations.
Yes. Every calculator here is free, needs no account and shows its working: the division ladder for prime factors, the test used for primes, each line of Euclid’s algorithm for the GCD, the square-and-multiply table for modular powers and the repeated divisions for base conversion.
The prime number checker accepts up to 200 digits, the modulo calculator up to 100 digits, and the prime factorization and GCD calculators up to 40 digits per number. The factorial calculator goes up to 10,000!, which has 35,660 digits. Factoring a large number whose prime factors are all big can take longer than the calculator allows; if so, it stops after about one second and says so.
No. A prime has exactly two distinct positive divisors, 1 and itself. The number 1 has only one divisor, so it is neither prime nor composite. Excluding it keeps prime factorizations unique.
Small numbers are checked by trial division. Larger ones go through the Miller–Rabin test with the 13 prime bases from 2 to 41, which is a proof for every number below about 3.3 × 10²⁴. Above that, a strong Lucas test is added (together, the Baillie–PSW test). No composite number is known to pass it, but the result is labeled a probable prime rather than a proven one.
The GCD is the largest number that divides all of your numbers, and the LCM is the smallest number that all of them divide. For 12 and 18, the GCD is 6 and the LCM is 36. For two positive numbers, GCD × LCM equals their product: 6 × 36 = 12 × 18 = 216.
Yes. The prime factorization calculator lists φ(n), the count of numbers from 1 to n that share no factor with n, next to the divisor count and divisor sum. For example, φ(360) = 96.
It is the number that “undoes” multiplication when you work with remainders: x is the inverse of a modulo n when ax leaves remainder 1. RSA uses one to turn the public key into the private key, and it is also how you solve congruences such as 17x ≡ 5 (mod 3120). An inverse exists only when a and n share no common factor.
There is no separate app to install. Every calculator here works in your phone’s browser, and you can add ScientifiCalc to your home screen to open it with one tap, like an app.