1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00

feat(challenges): add prime-numbers-decomposition

This commit is contained in:
Divlo 2021-10-16 15:15:37 +02:00
parent 0a27b9e1a1
commit 74ded41d4d
No known key found for this signature in database
GPG Key ID: 6F24DA54DA3967CF
16 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,36 @@
# prime-numbers-decomposition
Created by [@Divlo](https://github.com/Divlo) 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
```txt
32
```
#### Output
```txt
2 * 2 * 2 * 2 * 2
```
See the `test` folder for examples of input/output.

View File

@ -0,0 +1 @@
4

View File

@ -0,0 +1 @@
2 * 2

View File

@ -0,0 +1 @@
151

View File

@ -0,0 +1 @@
151

View File

@ -0,0 +1 @@
32

View File

@ -0,0 +1 @@
2 * 2 * 2 * 2 * 2

View File

@ -0,0 +1 @@
1358280

View File

@ -0,0 +1 @@
2 * 2 * 2 * 3 * 3 * 5 * 7 * 7 * 7 * 11

View File

@ -0,0 +1 @@
1433250

View File

@ -0,0 +1 @@
2 * 3 * 3 * 5 * 5 * 5 * 7 * 7 * 13

View File

@ -0,0 +1 @@
31861

View File

@ -0,0 +1 @@
151 * 211

View File

@ -0,0 +1 @@
31243

View File

@ -0,0 +1 @@
157 * 199