Algorithm of decomposition in product of factors first
In Mathematical, in the branch of the modular Arithmetic , a algorithm of decomposition in product of factors first is a algorithm (a process step by step) by which a whole “is broken up” into a product of factors which are prime numbers. The fundamental Théorème of arithmetic the ensures that this decomposition is Unique.
A simple algorithm of factorization
Description
We can describe a recursive algorithm to achieve such factorizations: that is to say a number given N
- if N is first, then factorization stops here.
- if N is composed, to divide N by the first prime number p 1. If it is divided without remainder, to begin again with the value N / p 1. To add p 1 to the list of the factors obtained for N / p 1 to have a factorization for N. If it is divided with remainder, to divide N by the prime number following p 2, and so on.
Note that we need to test only the prime numbers p I such as p I ≤ √ N .
Example
Let us suppose that we wish to factorize 9.438.9.438/2 = 4.719, without remainder thus 2 is a factor.
We repeat the algorithm with 4.719.
4.719/2 = 2 359.5, therefore 2 is not a factor. 4.719/3 = 1.573, therefore 3 is a factor.
The first prime number by which 1.573 is divisible is 11.
1.573/11 = 143. In a similar way, the prime number following which divides 143 is 11. 143/11 = 13. 13 are itself first.
Therefore, while recapitulating, we have 9.438 = 2*3*11*11*13
Here the example in python:
importation maths, sys def factorize (N): def isPrime (N): return not for X in xrange (2, int (math.sqrt (N))) yew n%x == 0] premiums = candidates = xrange (2, n+1) candidate = 2 while not premiums and candidate in candidates: yew n%candidate == 0 and isPrime (candidate): primes.append (candidate) premiums = premiums + factorize (n/candidate) candidate += 1 return premiums print factorize (int (sys.argv))
Exit: python factorize.py 9438 3,11,11,13
Complexity
The algorithm describes above goes well for small N , but becomes impracticable as soon as N becomes larger. For example, for a number of 18 decimal digits (or 60 digits Bit S), all the prime numbers lower than 1.000.000 000 must be tested, which becomes long, even for a Ordinateur. By adding two decimal digits to the original number, one multiplies calculation by 10.
The difficulty of factorization (complexity in broad time) in fact an ideal base for the modern Cryptology.
See also: Theorem of Euler, Decomposition in product of factors first, Tests of divisions
External bond
- Premium factorization At Mathworld
| Random links: | Conk gadget | Orgeval (Yvelines) | 89 (number) | Marc Thibault | Herois C Mar | Homer,_l'Illinois |