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,Mathematics

dCode and you

dCode is free and its tools are a valuable help in games, puzzles and problems to solve every day!
You have a problem, an idea for a project, a specific need and dCode can not (yet) help you? You need custom development? Contact-me!

Team dCode read all messages and answer them if you leave an email (not published). It is thanks to you that dCode has the best Prime Factors Decomposition tool. Thank you.

This page is using the new English version of dCode, please make comments !

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 we start again by taking $$N = N/p$$ as long as there are any possible divisors.

Consider the number $$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$$, you begin by attempting the division by $$2$$, $$147$$ is not divisible by $$2$$. You then divide by $$3$$, $$147/3 = 49$$ so $$147$$ is divisible by $$3$$ and $$3$$ is a prime factor of $$147$$. Then, you no longer consider $$147$$ but $$147/3 = 49$$. The prime numbers less than $$49$$ are $$2, 3, 5, 7, 11, 13, ...$$ You try to divide $$49$$ by $$2$$ and so on.

Finally, you'll get the factors $$3, 7, 7$$ and you can check that $$3 * 7 * 7 = 149$$, an you can also 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. 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, etc.) which dCode owns rights can be transferred after sales quote. So if you need to download the Prime Factors Decomposition script for offline use, for you, your company or association, see you on contact page !