30 lines
415 B
Python
30 lines
415 B
Python
import random, math
|
|
|
|
n = random.getrandbits(50)
|
|
print(n)
|
|
|
|
k = 2
|
|
pom = math.sqrt(n)
|
|
factors = [1]
|
|
i = 1
|
|
d = -1
|
|
while n > 1 and k <= pom:
|
|
while n % k == 0:
|
|
n = n // k
|
|
factors.append(k)
|
|
if k < 3:
|
|
k += 1
|
|
else:
|
|
k = 6 * i + d
|
|
if d == 1:
|
|
d = -1
|
|
i += 1
|
|
else:
|
|
d = 1
|
|
|
|
if len(factors) == 0:
|
|
factors.append(n)
|
|
|
|
print(factors)
|
|
|