1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-07-18 02:20:12 +02:00
programming-challenges/challenges/prime-numbers-decomposition
2023-08-10 11:13:06 +02:00
..
solutions fix(solutions): memory issues thanks to -fsanitize=address flag with gcc 2023-08-10 11:13:06 +02:00
test feat(challenges): add prime-numbers-decomposition 2021-10-16 15:15:37 +02:00
README.md fix: update author - Théo LUDWIG 2023-07-02 17:28:54 +02:00

prime-numbers-decomposition

Created by @theoludwig on 16 October 2021.

Instructions

Definition

In mathematics, product decomposition of prime factors (also known as integer factorization into prime numbers) involves writing a strictly positive integer as a product of prime numbers.

This factorization is unique and exists for all numbers and has many applications, particularly in RSA cryptography.

Note : A prime number is a natural integer which admits exactly two distinct positive divisors. (1 and itself). Example: 2, 3, 5, 7, 11, 13, 17, 19...

How to decompose a number into a product of factors of prime numbers?

To find the product decomposition of prime factors of a number N, there is no mathematical formula. To achieve this, there are algorithms, the most basic of which attempts 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 a new N = N / p as long as there are possible prime divisors.

Examples

Example

Input

32

Output

2 * 2 * 2 * 2 * 2

See the test folder for examples of input/output.