|
D.2.2.19 primefactors
Procedure from library general.lib (see general_lib).
- Usage:
primefactors(n [,p]); n = int or number, p = integer
- Compute:
primefactors <= min(p,32003) of n (default p = 32003)
- Return:
a list, say l,
l[1] : primefactors <= min(p,32003) of n
l[2] : l[2][i] = multiplicity of l[1][i]
l[3] : remaining factor ( n=product{ (l[1][i]^l[2][i])*l[3]} )
type(l[3])=typeof(n)
- Note:
If n is a long integer (of type number) then the procedure
finds primefactors <= min(p,32003) but n may be larger as
2147483647 (max. integer representation)
- Warning:
the procedure works for small integers only, just by testing all
primes (not to be considerd as serious prime factorization!)
Example:
| LIB "general.lib";
primefactors(7*8*121);
→ [1]:
→ 2,7,11
→ [2]:
→ 3,1,2
→ [3]:
→ 1
ring r = 0,x,dp;
primefactors(123456789100);
→ [1]:
→ 2,5
→ [2]:
→ 2,2
→ [3]:
→ 1234567891
|
|