Skip to main content
ponderloop

Prime Factorization Calculator

To find the prime factorization of a number, divide it by the smallest prime that fits and repeat with the quotient until only primes are left: 360 = 2³ × 3² × 5 (2 × 2 × 2 × 3 × 3 × 5). That also gives its 24 divisors, which add up to 1170, and Euler’s totient φ(360) = 96. A number is prime when it has no divisors but 1 and itself: 97 is prime, while 91 = 7 × 13. The primes next to 360 are 359 and 367. Enter any whole number up to 30 digits for its factor tree, divisor list and neighbouring primes, or list every prime up to 1,000,000.

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

Any whole number from 1 up to 30 digits. Commas and spaces are fine: 1,234,567.

Prime factorization of 360

2³ × 3² × 5

360 is composite: 2 × 2 × 2 × 3 × 3 × 5, 6 prime factors counting repeats, 3 different.

Is it prime?
No, composite
Prime factorization
2³ × 3² × 5
As a product
2 × 2 × 2 × 3 × 3 × 5
Number of divisors
24
Sum of divisors
1170
Euler’s totient φ(n)
96
Previous prime
359
Next prime
367

Factor tree

Each composite number splits into its smallest prime factor and what is left, until only primes remain. The primes at the ends of the branches are the factorization.

Factor tree of 360360 splits into 2 and 180. 180 splits into 2 and 90. 90 splits into 2 and 45. 45 splits into 3 and 15. 15 splits into 3 and 5. The prime factors are the leaves: 2, 2, 2, 3, 3, 5.360218029024531535

The same tree as a list

  • 360 splits into
    • 2 prime
    • 180 splits into
      • 2 prime
      • 90 splits into
        • 2 prime
        • 45 splits into
          • 3 prime
          • 15 splits into
            • 3 prime
            • 5 prime

Divisors

All 24 divisors of 360, smallest first.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 8
  • 9
  • 10
  • 12
  • 15
  • 18
  • 20
  • 24
  • 30
  • 36
  • 40
  • 45
  • 60
  • 72
  • 90
  • 120
  • 180
  • 360

Primes up to N

There are 25 primes up to 100; the largest is 97.

  • 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

Prime factorizations of common numbers

Worked out by the calculator above. The divisor count is the product of each exponent plus one.
NumberPrime factorizationDivisorsSum of divisorsTotient φ(n)
122² × 36284
182 × 3²6396
242³ × 38608
362² × 3²99112
482⁴ × 31012416
602² × 3 × 51216816
722³ × 3²1219524
842² × 3 × 71222424
902 × 3² × 51223424
962⁵ × 31225232
1002² × 5²921740
1202³ × 3 × 51636032
1442⁴ × 3²1540348
1802² × 3² × 51854648
2102 × 3 × 5 × 71657648
3602³ × 3² × 524117096
7202⁴ × 3² × 5302418192
10002³ × 5³162340400
10242¹⁰112047512
20253⁴ × 5²1537511080

Numbers with many divisors

Each is the smallest number with more divisors than any smaller number, which is why 12, 60 and 360 turn up in clocks, angles and calendars.
NumberPrime factorizationDivisors
122² × 36
602² × 3 × 512
3602³ × 3² × 524
5,0402⁴ × 3² × 5 × 760
55,4402⁴ × 3² × 5 × 7 × 11120
720,7202⁴ × 3² × 5 × 7 × 11 × 13240

Miller–Rabin witness sets used for the prime test

Testing the first k primes as witnesses gives a proven answer for every n below the bound (OEIS A014233; Sorenson & Webster 2015 for the last two). From 3,317,044,064,679,887,385,961,981 up, the tool uses the first 20 primes and calls a passing number a probable prime.
Proven for n belowWitnesses (first primes)How many
2,04721
1,373,6532, 32
25,326,0012, 3, 53
3,215,031,7512, 3, 5, 74
2,152,302,898,7472, 3, 5, 7, 115
3,474,749,660,3832, 3, 5, 7, 11, 136
341,550,071,728,3212, 3, 5, 7, 11, 13, 177
3,825,123,056,546,413,0512, 3, 5, 7, 11, 13, 17, 19, 239
318,665,857,834,031,151,167,4612, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 3712
3,317,044,064,679,887,385,961,9812, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 4113
3,317,044,064,679,887,385,961,981 and up2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 7120 (probable prime)

How to find the prime factorization of a number by hand

  1. Divide by the smallest prime that goes in. Try 2, then 3, 5, 7 and so on. 360 is even, so divide by 2: 360 ÷ 2 = 180. Keep dividing by the same prime while it still goes in: 180 ÷ 2 = 90, 90 ÷ 2 = 45.
  2. Move to the next prime when it stops going in. 45 is odd, so try 3: 45 ÷ 3 = 15 and 15 ÷ 3 = 5. Then 5 is prime and the division ends.
  3. Stop when the square of the prime passes what is left. You only need to try primes p with p × p no larger than the remaining number; if none goes in, what is left is prime. This is why 97 is prime: no prime up to 9 divides it.
  4. Collect the primes and write exponents. The primes you divided out are 2, 2, 2, 3, 3 and 5, so 360 = 2 × 2 × 2 × 3 × 3 × 5 = 2³ × 3² × 5. Draw the same split as a factor tree if you want a picture.
  5. Get the divisor count from the exponents. Add 1 to each exponent and multiply: (3 + 1)(2 + 1)(1 + 1) = 24 divisors of 360.

Frequently asked questions

What is prime factorization?
It is writing a whole number greater than 1 as a product of primes. By the fundamental theorem of arithmetic every such number has exactly one prime factorization, apart from the order of the factors. 360 = 2³ × 3² × 5, and no other set of primes multiplies to 360.
How do I know if a number is prime?
A prime has exactly two divisors, 1 and itself. To check by hand, divide by every prime whose square is no more than the number: 97 has no divisor among 2, 3, 5 and 7, so it is prime, while 91 = 7 × 13 is not. The calculator uses the Miller–Rabin test, which is proven correct for every number below 3,317,044,064,679,887,385,961,981.
Is 1 a prime number?
No. A prime has exactly two divisors, and 1 has only one. Calling 1 prime would also break the uniqueness of prime factorization, because 6 = 2 × 3 = 1 × 2 × 3 = 1 × 1 × 2 × 3 and so on. 1 is neither prime nor composite; it is the empty product.
What is a factor tree?
A diagram that splits a number into two factors, then splits each composite factor again until every branch ends in a prime. Here 360 splits into 2 and 180, then 180 into 2 and 90, and so on to the leaves 2, 2, 2, 3, 3 and 5. The tool always splits off the smallest prime, so the tree has one shape for each number. The drawing has a text description and the same tree is given as a nested list for screen readers.
How do I count the divisors of a number?
Factor it, add 1 to each exponent and multiply. 60 = 2² × 3 × 5, so it has (2 + 1)(1 + 1)(1 + 1) = 12 divisors. The sum of the divisors is the product of (p^(e+1) − 1)/(p − 1) for each prime power: 60 gives 168. 12 has 6 divisors adding up to 28.
What is Euler’s totient function?
φ(n) counts the numbers from 1 to n that share no factor with n. From the factorization, φ(n) = n × the product of (1 − 1/p) over the distinct primes p. For 36 = 2² × 3² that is 36 × 1/2 × 2/3 = 12. For a prime p, φ(p) = p − 1: φ(97) = 96. It is used in RSA key generation and in modular arithmetic.
How does it find the factors of a big number?
It divides out every prime below 10,000 first, then tests what is left for primality with Miller–Rabin and, if it is composite, uses Pollard’s rho algorithm (Brent’s variant) to find a factor. That factors a number like 600851475143 = 71 × 839 × 1471 × 6857 instantly. Everything runs in a background thread in your browser, so the page stays responsive.
Why does it say “too hard to factor here” for some numbers?
Pollard’s rho takes about the square root of the smallest prime factor in steps, so a number made of two primes of about 14 digits each needs about ten million big-number steps. The tool gives each number a few seconds and then shows what it found so far. Numbers like that are exactly what RSA relies on being hard to factor; serious factoring uses methods such as the quadratic or number field sieve on many machines.
Is a very large result really prime?
Below 3,317,044,064,679,887,385,961,981 (about 3.3 × 10²⁴) the answer is proven, because the Miller–Rabin witness sets are known to have no exceptions there. Above that the tool tests 20 prime bases and labels a passing number “probable prime”: no number is known that passes all of them and is composite, but there is no proof. Composite answers are always certain, since a single failing witness proves a number composite.
How many primes are there up to 100 and up to 1,000,000?
There are 25 primes up to 100 and 78,498 up to 1,000,000, the largest of them being 999,983. The “Primes up to N” list uses the Sieve of Eratosthenes, which crosses out the multiples of each prime in turn, and shows the first 1,000 primes.
Which numbers are the next and previous prime?
They are the closest primes above and below the number you enter. For 360 they are 367 and 359. Prime gaps grow slowly (about the number of digits times 2.3 on average), so the search is quick even for 30-digit numbers.
How do I use prime factors to find the GCD or LCM?
Write both numbers in exponent form: 18 = 2 × 3² and 24 = 2³ × 3. The GCD takes each shared prime to the smaller exponent (2 × 3 = 6) and the LCM takes every prime to the larger exponent (2³ × 3² = 72).

How it works

The number is read as a whole number of up to 30 digits and held as a BigInt, so there is no rounding. Primality uses the Miller–Rabin strong probable-prime test with fixed witnesses: for n below 3,317,044,064,679,887,385,961,981 the witness sets from OEIS A014233 (Jaeschke 1993; Sorenson & Webster 2015) make the test deterministic, and above that bound the first 20 primes are tried and a pass is reported as a probable prime. Factoring divides out every prime below 10,000, then splits what remains with Pollard’s rho in Brent’s variant (pseudo-random map x² + c, cycle detection by Brent’s method, gcds taken in batches of 128 steps), recursing until every piece passes the primality test; perfect squares are split by an integer square root. Each number gets a time budget of a few seconds; if factoring does not finish, the tool shows the factors found and the unfactored remainder. The divisor count is the product of (e + 1), the divisor sum the product of (p^(e+1) − 1)/(p − 1), and φ(n) the product of p^(e−1)(p − 1). Next and previous primes are found by testing the odd numbers above and below. “Primes up to N” is the Sieve of Eratosthenes for N up to 1,000,000; the count is exact and at most 1,000 primes are listed. Everything runs in your browser and nothing you type is sent anywhere.

Sources

All toolsHome & DIY calculators