Prime Factorization Calculator Widget

Let students break any whole number up to 10^12 into primes. The widget says whether the number is prime, writes the factorization with exponents such as 2^3 x 3^2 x 5, and gives the number of divisors, their sum and - when there are not too many - the full list.

Education & Math Calculator Runs in your browser Free · no ads

Customize your widget

Theme
Auto follows the visitor's light/dark setting.
Style
Attribution on your page
Optional and entirely your choice. The exact line is shown in the code below; it links to the tool with rel="nofollow".
More options
Starting values
Leave blank to use the widget's defaults. Visitors can still change every value.

Live preview

Exactly what your visitors will see

Embed code

<iframe src="https://a2z.tools/embed/w/prime-factorization-calculator" title="Prime Factorization Calculator by A2Z Tools" width="100%" height="480" style="border:0;width:100%" loading="lazy" allow="clipboard-write"></iframe>

A plain iframe. Works everywhere, including site builders that strip scripts. Adjust height if your content needs more room.

Works with

How it works

Trial division strips out 2 and 3, then tests only numbers of the form 6k - 1 and 6k + 1 up to the square root of what remains, because every prime above 3 has that form. Whatever is left above 1 at the end is itself prime. For inputs up to one trillion that is at most about 333,000 divisions, which finishes instantly and stays exact in ordinary double-precision arithmetic. From the factorization p1^e1 x p2^e2 ..., the number of divisors is (e1 + 1)(e2 + 1)..., and the sum of divisors multiplies the geometric series 1 + p + ... + p^e for each prime, adding terms one at a time so that nothing overflows. When there are 64 divisors or fewer they are listed in order. The number 1 is reported as neither prime nor composite, 0 is refused because every prime divides it, and the copy button gives a plain-text form such as 360 = 2^3 x 3^2 x 5.

Calculation method

  • Trial division by 2, 3, then 6k - 1 and 6k + 1 while divisor^2 <= remaining value
  • n = p1^e1 x p2^e2 x ... x pk^ek
  • Number of divisors d(n) = (e1 + 1)(e2 + 1)...(ek + 1)
  • Sum of divisors = product of (1 + p + p^2 + ... + p^e)

Worked examples

A highly composite number

Inputs: 360

Result: 2^3 x 3^2 x 5; 24 divisors; sum 1,170

360 / 2 / 2 / 2 = 45, 45 / 3 / 3 = 5.

A round trillion

Inputs: 1,000,000,000,000

Result: 2^12 x 5^12; 169 divisors; sum 2,499,694,822,171

(2^13 - 1)(5^13 - 1) / 4 = 8191 x 305,175,781.

Limitations

  • Inputs above 10^12 are refused; very large numbers need algorithms such as Pollard's rho.
  • Negative numbers are not factorized - factor the absolute value and add -1 yourself.
  • The full divisor list is shown only when there are at most 64 divisors.

Where publishers use it

  • Number-theory and factor-tree lessons in middle school
  • Olympiad and aptitude-test preparation pages
  • Programming challenge write-ups, such as finding the largest prime factor
  • Cryptography introductions showing why factoring large numbers is hard
  • Puzzle sites working with perfect numbers and divisor sums

Questions

Why is 1 not a prime number?

A prime has exactly two divisors, 1 and itself; 1 has only one. Excluding it keeps factorizations unique: otherwise 6 could be written as 2 x 3, 1 x 2 x 3, 1 x 1 x 2 x 3 and so on.

How many divisors does 360 have?

360 = 2^3 x 3^2 x 5, so it has (3 + 1)(2 + 1)(1 + 1) = 24 divisors, and they add up to 15 x 13 x 6 = 1,170.

What is the largest prime factor of 600851475143?

6857. The number factors as 71 x 839 x 1471 x 6857, the well-known Project Euler problem 3, and the widget finds it in a moment.

Why stop at one trillion?

Trial division needs up to sqrt(n) checks. At 10^12 that is a million candidates, about 333,000 once multiples of 2 and 3 are skipped, still instant; far larger numbers would freeze the page and need advanced algorithms.

Is 999,999,999,989 prime?

Yes - it is the largest prime below one trillion, and the widget confirms it while listing just two divisors, 1 and itself.

What is a perfect number?

A number whose divisors, excluding itself, add up to the number - equivalently, whose sum of divisors is twice the number. 6 (1 + 2 + 3), 28, 496 and 8,128 are the first four. If the sum is larger the number is called abundant (12), if smaller deficient (8).

Why do primes matter for internet security?

RSA encryption publishes a modulus that is the product of two huge secret primes. Multiplying them is easy, but recovering the factors of a 600-digit semiprime is far beyond any known method, which is what keeps the private key safe. This widget's limit of 12 digits shows how quickly factoring gets hard.

Cite or recommend this tool

If you reference this tool in an article, course or documentation, these formats are ready to copy. They are optional - nothing is added to your site unless you paste it.

A2Z Tools Prime Factorization Calculator
https://a2z.tools/embed/prime-factorization-calculator
  • LCM and GCD Calculator

    Education & Math Calculator New

    Greatest common divisor (HCF) and least common multiple of 2 to 10 numbers, with Euclid's steps.

    Get code
  • Number Base Converter

    Education & Math Converter

    Binary, octal, decimal, hex and any base from 2 to 36 - exact for very large integers.

    Get code
  • Scientific Calculator

    Education & Math Calculator

    Trig in degrees or radians, logs, roots, powers, factorials, pi, e and Ans - typed or tapped.

    Get code
  • Percentage Calculator

    Education & Math Calculator

    X% of Y, X as a percent of Y, and the percentage change between two values.

    Get code
  • Basic Calculator

    Education & Math Calculator

    A clean on-screen calculator with keyboard support, correct operator precedence and percent.

    Get code
  • Fraction Calculator

    Education & Math Calculator

    Add, subtract, multiply and divide fractions and mixed numbers, with the simplified answer.

    Get code

Preview