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.

# 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.

Example: 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$$, 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 consider $$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 = 149$$, 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;};