Your uncle Omar has asked for your help. Back in the 1980s, he encrypted some personal documents using RSA encryption, but he lost his private key. He waited years for computers to become powerful enough to unlock his key, but then forgot about the documents until last week.
Can you help him recover the documents by factoring this large number for him?
26390 85015 23339 22027 40949 38630 97432 59521 51779 38861 43240 989
Please submit your answer by entering the digit sum of the smallest prime factor.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Exactly what I did
Can anyone check and tell me what's wrong with my code? I don't see anything wrong and it works for small numbers. I got the answer as 29 (which on summing is 11) -
public static void main(String a[]){
final double num = 2639085015233392202740949386309743259521517793886143240989d;
for(double i = 3d;;i++)
if(num % i == 0)
if(prime(i)){
System.out.println(i);
break;
}
}
static boolean prime(double n) {
if (n%2==0) return false;
for(double i=3;i*i<=n;i+=2)
if(n%i==0)
return false;
return true;
}
I just loop through numbers, check if they can divide the large number without any remainder and if a number does that, then check if it is prime. If it is, then print out the answer
I see no way of solving this except using a number field,quadratic sieve or GMP-ECM.
> The quadratic sieve algorithm (QS) is an integer factorization algorithm and, in practice, the second fastest method known (after the general number field sieve). It is still the fastest for integers under 100 decimal digits or so, and is considerably simpler than the number field sieve. It is a general-purpose factorization algorithm, meaning that its running time depends solely on the size of the integer to be factored, and not on special structure or properties. It was invented by Carl Pomerance in 1981 as an improvement to Schroeppel's linear sieve.[1]
More Here
The Lenstra elliptic curve factorization or the elliptic curve factorization method (ECM) is a fast, sub-exponential running time algorithm for integer factorization which employs elliptic curves. For general purpose factoring, ECM is the third-fastest known factoring method. The second fastest is the multiple polynomial quadratic sieve and the fastest is the general number field sieve. The Lenstra elliptic curve factorization is named after Hendrik Lenstra. Practically speaking, ECM is considered a special purpose factoring algorithm as it is most suitable for finding small factors. Currently, it is still the best algorithm for divisors not greatly exceeding 20 to 25 digits (64 to 83 bits or so), as its running time is dominated by the size of the smallest factor p rather than by the size of the number n to be factored. Frequently, ECM is used to remove small factors from a very large integer with many factors; if the remaining integer is still composite, then it has only large factors and is factored using general purpose techniques. The largest factor found using ECM so far has 83 digits and was discovered on 7 September 2013 by R. Propper.[1] Increasing the number of curves tested improves the chances of finding a factor, but they are not linear with the increase in the number of digits.
At first I tried brute forcing with the first fifty million primes but that didn't work,Either because none of them really factorized the number or because python was unable to handle the large size of the problem. It felt like cheating but after days of fruitless labour,I just used GMP-ECM( pyecm ) to factorize the monster of a number.
Use http://www.numberempire.com/numberfactorizer.php?number=2639085015233392202740949386309743259521517793886143240989
Takes less than 0.5 seconds, wow.
Mathematica: 2 6 3 9 0 8 5 0 1 5 2 3 3 3 9 2 2 0 2 7 4 0 9 4 9 3 8 6 3 0 9 7 4 3 2 5 9 5 2 1 5 1 7 7 9 3 8 8 6 1 4 3 2 4 0 9 8 9 = 3 1 6 7 3 6 4 2 2 0 4 8 4 4 1 0 9 8 8 7 2 2 6 6 5 6 0 1 × 8 3 3 2 1 1 7 2 7 9 6 1 5 4 6 2 9 9 7 7 5 9 6 2 0 0 2 5 8 9
What happens if we express the number in terms of a large prime (say 99991 which is the largest 5 digit prime) and then reduce the factorization of the number to polynomial factorization and / or factorization of the individual digits ?
Mathematica enhanced :
g = 2639085015233392202740949386309743259521517793886143240989;
k = 2;
While[a, If[Mod[g, Prime[k]] == 0, a = False]; k = k + 1];
Print[Prime[k-1]];
Sage:
n = 2639085015233392202740949386309743259521517793886143240989
k = factor(n)
print( sum(k[0][0].digits()) )
Runs in 8.11 seconds on my machine. I believe Sage uses an underlying quadratic sieve algorithm by default, though one can access GMP-ECM by using "ecm.factor()". For some reason, although theoretically faster for semiprime numbers around 50 digits or so, ECM took a significantly greater time on my machine but the breakdown attributed most of the time as wall time, and ECM took less CPU time (than quadratic sieve).
About how long does that program take to run?
≈ 25 seconds
Problem Loading...
Note Loading...
Set Loading...
In Mathematica, we use
which returns
in about two minutes on my machine. The smallest prime factor of our number is the first element of the above list: 3 1 6 7 3 6 4 2 2 0 4 8 4 4 1 0 9 8 8 7 2 2 6 6 5 6 0 1 , the digit sum of which is 1 1 5 .