Search for a tool
Prime Factors Decomposition

Tool to decompose in prime factors. In Mathematics, the prime factors decomposition (also known as Prime Integer Factorization) consists in writing a positive integer with a product of prime factors

Results

Prime Factors Decomposition -

Tag(s) : Arithmetics

Share
dCode and you

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!

Team dCode likes feedback and relevant comments; to get an answer give an email (not published). It is thanks to you that dCode has the best Prime Factors Decomposition tool. Thank you.

# Prime Factors Decomposition

## Fraction A/B Prime Numbers Factorization

Tool to decompose in prime factors. In Mathematics, the prime factors decomposition (also known as Prime Integer Factorization) consists in writing a positive integer with a product of prime factors

### How to decompose a number in a series of prime factors?

The decomposition into prime factors of a number $$N$$ requires attempting to divide the number $$N$$ by the set of prime factors $$p$$ which are less than $$N$$. If $$p$$ is a divisor of $$N$$ then start again by taking $$N = N/p$$ as long as there are any possible divisors.

Example: If $$N = 147$$, the prime numbers less than $$N = 147$$ are $$2, 3, 5, 7, 11, 13, ...$$. To find the decomposition into a product of prime factors of $$147$$, begin by attempting the division by $$2$$, $$147$$ is not divisible by $$2$$. Then divide by $$3$$, $$147/3 = 49$$ so $$147$$ is divisible by $$3$$ and $$3$$ is a prime factor of $$147$$. Then, no longer take $$147$$ but $$147/3 = 49$$. The prime numbers less than $$49$$ are $$2, 3, 5, 7, 11, 13, ...$$, try to divide $$49$$ by $$2$$ and so on.

Example: Finally, it remains the factors $$3, 7, 7$$ and check that $$3 * 7 * 7 = 147$$, or write $$147 = 3 * 7 ^ 2$$.

This decomposition is possible whatever the starting number, it is a fundamental theorem of arithmetic.

### How to code a prime factor decomposition?

// javascript function prime_factors(n) { if (!n || n < 2) return []; var f = []; for (var i = 2; i <= n; i++){ while (n % i === 0){ f.push(i); n /= i; } } return f;};

## Source code

dCode retains ownership of the source code of the script Prime Factors Decomposition online. Except explicit open source licence (indicated Creative Commons / free), any algorithm, applet, snippet, software (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or any function (convert, solve, decrypt, encrypt, decipher, cipher, decode, code, translate) written in any informatic langauge (PHP, Java, C#, Python, Javascript, Matlab, etc.) which dCode owns rights will not be released for free. To download the online Prime Factors Decomposition script for offline use on PC, iPhone or Android, ask for price quote on contact page !