U

Prime Factorization Calculator

Analyze the prime factorization of any number up to 99,999: find the smallest and largest prime factors, the exponent of the smallest factor and the remaining cofactor.
Input

Prime factors

Breakdown

Largest prime factor
0

Key Assumptions

  • Input number is a positive integer greater than 1.
  • The engine loops via repeated division; no recursive function calls.
  • Field keys avoid reserved mathjs names and use simple descriptive names.

Formula Used

Prime factorisation: repeated division by primes starting from 2.
Embed this calculator on your website

Add this embed page to your site — visitors use the calculator right from your page.

Every whole number greater than one can be built from prime numbers, and this prime factorization calculator shows you those building blocks at a glance. Enter any number from 2 to 99,999 and the tool reports the smallest prime factor, how many times that factor divides the number, the cofactor that remains, and the largest prime factor. It also tells you in a single flag whether the number itself is prime, giving a complete picture of the factorization boundary without requiring you to work through dozens of divisions by hand.

What Is Prime Factorization?

Prime factorization is the process of writing a whole number as a product of prime numbers, where a prime is any integer greater than one that has exactly two positive divisors. The number 12 factors as 2 x 2 x 3, and the number 360 factors as 2 x 2 x 2 x 3 x 3 x 5. These results are usually written compactly with exponents: 12 = 2 squared times 3, and 360 = 2 cubed times 3 squared times 5.

The fundamental theorem of arithmetic guarantees that this decomposition is unique for every number. No matter how you start peeling factors apart, you always arrive at the same list of primes. That uniqueness is what makes factorization useful: it gives every integer a canonical identity made of primes, much as a fingerprint identifies a person.

How to Find the Prime Factors of a Number

The most direct method is trial division. Start with the smallest prime, 2, and test whether it divides the number cleanly. If it does, divide and test again, because the same prime can appear more than once. When the number no longer divides by 2, move to 3, then 5, 7, 11 and so on, working upward through the primes.

For 360 the process is short: it divides by 2 three times, by 3 twice, and by 5 once, leaving the factorization 2 cubed times 3 squared times 5. For a prime such as 97, no candidate divides it, and the conclusion is that the number is prime itself. The calculator automates this trial division with a fixed chain of the first 25 primes.

Using the Prime Factorization Calculator

Set the number to factor with the slider or type a value directly into the input box. The results panel updates immediately. The headline outputs are the smallest prime factor, the exponent of that factor, the remaining cofactor and the largest prime factor, with a final flag for whether the input is prime.

Take 360 as a default example. The smallest prime factor is 2, and the exponent is 3, meaning 2 appears three times. Dividing 360 by 2 cubed leaves a cofactor of 45. The largest prime factor is 5, and the prime flag reads 0 because 360 is composite. Every line of that report is derived from the same trial-division arithmetic.

Reading the Results

The smallest prime factor is the first building block and the fastest information to extract. If it is 2, the number is even; if it is 3, its digits sum to a multiple of three; if it equals the input itself, the input has no smaller divisor and the search is done. This single number often tells you most of what you need for quick mental arithmetic.

The exponent records how many copies of that prime appear in the factorization. The exponent of 2 in 360 is 3, while in 12 it is 2 and in 8 it is 3. Together with the smallest prime factor, the exponent compresses the first step of the factorization into two numbers: the prime and its power.

The Remaining Cofactor

The cofactor is what is left after you divide out the full power of the smallest prime factor. For 360, removing 2 cubed leaves 45, which then factors into 3 squared times 5. For a prime input the cofactor collapses to 1, because dividing the number by its only factor leaves nothing behind.

The cofactor is the natural place to continue a hand factorization. Run the same trial division on the cofactor, and you peel off the next prime factor. Chaining these steps reproduces the complete factorization of any number, which is why the cofactor line is the bridge between the calculator and a full by-hand breakdown.

The Largest Prime Factor

The largest prime factor is the final, heaviest block in the factorization. The calculator finds it by checking the same 25 primes in descending order: 97, 89, 83 and so on down to 2. The first one that divides the number cleanly is the largest chain prime that appears in its factorization.

For 360 the largest prime factor is 5, because the primes above 5 do not divide 360. For 84 it is 7, and for 291, which factors as 3 times 97, it is 97. Large prime factors are special in mathematics because recovering them from a huge product is genuinely difficult, which is the entire foundation of RSA encryption.

Why the Search Stops at the Square Root

Trial division does not need to test every possible divisor. If a number n is composite, written as a times b, then at least one of a or b must be no larger than the square root of n. If both factors sat above the root, their product would exceed n. Checking all candidates up to and including the square root therefore guarantees that every composite number will be caught.

This is why the largest possible factor of any number is floor of its square root. For 360 the root is about 18.97, so no factor of 360 exceeds 18; for a prime like 89, only the candidates from 2 through 9 need checking before the conclusion is forced. The bound shrinks the search dramatically as numbers grow.

The Prime Flag

The prime flag is a simple binary result built from the same trial division. When no prime in the chain divides the input, the smallest prime factor equals the input itself, and the flag reports 1, meaning the number is prime. When a divisor is found, the flag reports 0 and the number is composite.

For a true prime such as 97 the answer is exact. For composite numbers whose prime factors all exceed 97, such as 101 times 103, the chain finds no divisor and reports the input as prime. This documented limitation follows directly from the fixed size of the divisor list, and it is stated plainly in the assumptions so the flag is never mistaken for a definitive proof.

Prime Factorization with Exponents

Exponents turn repeated multiplication into compact notation. Instead of writing 2 x 2 x 2, you write 2 cubed, and instead of 3 x 3, you write 3 squared. The exponent counts the copies of the base prime, and the full factorization is a product of prime powers.

The exponent of the smallest prime factor is the first such count, and the calculator reports it directly. For a number like 512, which is 2 to the ninth power, the smallest prime factor is 2 and the exponent is 9, while the cofactor is 1. Prime powers like this are the cleanest case: one prime, one exponent, and nothing left over.

Prime Factorization and Number Theory

Factorization sits beneath a surprising amount of mathematics. The greatest common divisor of two numbers is the product of their shared primes at the lowest exponent, and the least common multiple takes every prime at the highest exponent. Fractions reduce by canceling shared prime factors, and ratios simplify by the same route.

The GCF calculator and the LCM calculator on this site automate those operations, and the fraction calculator uses the same underlying logic to simplify ratios. Understanding the prime factors of a number makes all of these tools easier to trust, because you can see the shared building blocks for yourself.

Worked Examples

Start with 360, the default. The smallest prime factor is 2, its exponent is 3, the cofactor is 45, and the largest prime factor is 5. The full factorization follows by factoring the cofactor: 45 is 3 squared times 5, so 360 equals 2 cubed times 3 squared times 5, which checks out when multiplied back.

Now try 84. The smallest prime factor is 2, the exponent is 2 because 84 divides by 4 but not by 8, and the cofactor is 21. The largest prime factor is 7, because 21 is 3 times 7. Factoring the cofactor gives 84 equals 2 squared times 3 times 7.

Finally take a prime like 97. No candidate divides it, so the smallest prime factor equals the input, the exponent is 1, the cofactor is 1, the largest prime factor is 97, and the flag reports 1. A prime produces the cleanest possible report because every line points to the same conclusion.

Honest Limits of the Tool

The calculator checks exactly 25 primes, from 2 to 97. Composites built entirely from larger primes, like 101 times 103, are reported as prime, and composites with a large prime factor, like 202, report the largest chain prime that divides them rather than the true largest factor. The exponent is exact whenever the smallest factor is 23 or below, and for factors above that it is reported as 1, which undercounts rare prime squares such as 29 squared.

These limitations all stem from the same design choice: the divisor list must be fixed in advance because the calculation engine evaluates a fixed chain of checks rather than looping over an unknown number of candidates. The assumptions list states each limitation explicitly, so the results never overstate their own accuracy.

Practical Uses

Students use factorization to practice arithmetic and prepare for gcd and lcm problems. Teachers use it to generate examples with predictable factor structures. Anyone exploring number theory can use the smallest and largest prime factors to understand the boundary of a number's divisibility, and the cofactor provides the next step whenever a full factorization is needed.

Key Assumptions

  • Only the 25 primes from 2 to 97 are tested; a number left undivided is reported as prime.
  • The exponent is exact for smallest factors up to 23 and reported as 1 above that.
  • The largest prime factor is exact when all prime factors are 97 or below.
  • The input is a whole number between 2 and 99,999.

Why Prime Factorization Matters

Prime numbers are the atoms of arithmetic. Every integer is built from them, and every computational shortcut from encryption to error-correcting codes leans on how hard it is to reverse that building process. Sliding the input to different values and watching the factorization boundary respond is a small window into that machinery.

Disclaimer

Results are provided as estimates for informational purposes only and may be inaccurate. Always verify outcomes with a qualified professional before making financial or personal decisions based on these calculations.

FAQs

Related Calculators