I have a 3000 digits long number must be factored into its prime numbers. I know that there are no prime factors larger than 104743.
Is this possible to do on a “normal” computer in a few minutes since the highest factor is relatively low?
As a reference, I tried this code I found here.
def factorize(n):
count = 0;
while ((n % 2 > 0) == False):
# equivalent to n = n / 2;
n >>= 1;
count += 1;
# if 2 divides it
if (count > 0):
print(2, count);
# check for all the possible
# numbers that can divide it
for i in range(3, int(math.sqrt(n)) + 1):
count = 0;
while (n % i == 0):
count += 1;
n = int(n / i);
if (count > 0):
print(i, count);
i += 2;
# if n at the end is a prime number.
if (n > 2):
print(n, 1);
n = 5*7*11*13*17*19*23*29*31*37*41*43*47;
factorize(n);
# This code is contributed by mits
This code use 59 seconds to factories a 18-digit number with 47 being the highest factor (102481630431415235 was the “test number”). If I stop at the 47th factor it use only 31 seconds, but it is still way too long with the test number being far lower than my need.