RosettaCodeData/Task/Prime-decomposition/11l/prime-decomposition.11l
2023-07-01 13:44:08 -04:00

22 lines
444 B
Text

F decompose(BigInt number)
[BigInt] result
V n = number
BigInt i = 2
L n % i == 0
result.append(i)
n I/= i
i = 3
L n >= i * i
L n % i == 0
result.append(i)
n I/= i
i += 2
I n != 1
result.append(n)
R result
L(i) 2..9
print(decompose(i))
print(decompose(1023 * 1024))
print(decompose(2 * 3 * 5 * 7 * 11 * 11 * 13 * 17))
print(decompose(BigInt(16860167264933) * 179951))