-7
Challenge
Write a program to factor this set of 10 numbers:
15683499351193564659087946928346254200387478295674004601169717908835380854917
24336606644769176324903078146386725856136578588745270315310278603961263491677
39755798612593330363515033768510977798534810965257249856505320177501370210341
45956007409701555500308213076326847244392474672803754232123628738514180025797
56750561765380426511927268981399041209973784855914649851851872005717216649851
64305356095578257847945249846113079683233332281480076038577811506478735772917
72232745851737657087578202276146803955517234009862217795158516719268257918161
80396068174823246821470041884501608488208032185938027007215075377038829809859
93898867938957957723894669598282066663807700699724611406694487559911505370789
99944277286356423266080003813695961952369626021807452112627990138859887645249
Each of these:
- Is a 77-digit number less than 2^256.
- Is a semiprime (e.g., the product of exactly 2 primes).
- Has something in common with at least one other number in the set.
Thus, this challenge is not about general factoring of 256-bit semiprimes, but about factoring these semiprimes. It is a puzzle. There is a trick. The trick is fun.
It is possible to factor each of these numbers with surprising efficiency. Therefore, the algorithm you choose will make a much bigger difference than the hardware you use.
Rules
- This is code-golf, so the shortest answer wins.
- You may use any method of factoring. (But don't precompute the answers and just print them. You program should do actual work.)
- You may use any programming language (or combination of languages), and any libraries they provide or you have installed. However, you probably won't need anything fancy.
1Does our solution have to theoretically work for any general semiprime less that 2^256, or just those? – BrainSteel – 2015-08-23T02:20:01.670
2@BrainSteel — Just these. However, it should actually do some work. Don't simply write a program that executes in 0.00 seconds that prints out the factorizations from hard-coded values after figuring them out using a slower method. :) – Todd Lehman – 2015-08-23T02:21:18.757
2You may throw any amount of hardware at the problem. Does that mean you aren't going to time the submissions yourself? – Dennis – 2015-08-23T02:51:48.433
@Dennis — In theory, I'd love to, but in practice, I'd really only be able to time simple C, C++, Java, Perl, or Python solutions. I don't have Haskell, Lisp, Clojure, Mathematica, etc. installed. In any case, throwing even the world's fastest compute cluster at this isn't likely to give the fastest result. – Todd Lehman – 2015-08-23T03:11:54.677
4But using the same algorithm on two different computers will. If your not going to test the solutions yourself, the scores will be unverifiable and the contest will boil down to who has the fastest computer. Most languages should be easy enough to install. If you choose this route, I'd recommend forbidding languages without a free interpreter. – Dennis – 2015-08-23T03:14:45.580
All right, I'll test them on my machine if I can. It's a 3.4 GHz 4-core i7. – Todd Lehman – 2015-08-23T04:43:28.003
"But it is possible to do it in the blink of an eye (literally)." - obviously; if you know the solutions already, you can tailor the code to "perform trial division" at "random", but with the seed set to a specific value, or things like that. (EDIT: Note that I do actually already know the 'secret' - it's pretty easy for a mathematician to guess it) – Glen O – 2015-08-23T04:47:17.197
3@GlenO Is it? I've tried William's p+1, Pollard's p-1, Fermat's near semi-primes, but none of them matched. To save others the effort, the factorization of the first number is 123830525223423718982054269884856893727 and 126652934104061135988638942588043498971. – orlp – 2015-08-23T05:03:45.143
1My problem with this "challenge" is that as soon as I post my solution, everyone will understand how to do it. @orld - think about the fact that Todd specifically said that you need to do it with this specific set of semiprimes. – Glen O – 2015-08-23T05:16:39.893
3I have a solution sitting ready to post, and it runs in milliseconds, but don't want to post it too quickly, because it gives away the puzzle. – Glen O – 2015-08-23T05:19:18.813
4@GlenO: This isn't puzzling.SE; IMO go ahead. (This challenge is flawed and doesn't really fit here, and I've downvoted it. It's a fine puzzle, but a horrible [tag:fastest-code] challenge.) – Lynn – 2015-08-23T05:20:52.563
I'm voting to close as lacking an objective winning criterion. After seeing @GlenO's answer, it's obvious that it will be impossible to accurately measure run time. – Dennis – 2015-08-23T05:27:07.930
@Dennis — I had marked this as
puzzle-solver
originally (also asfastest-code
), but someone edited it and removed the tag. I've edited it to change this to acode-golf
(shortest answer) problem. Glen's excellent solution is already golfed! :) – Todd Lehman – 2015-08-23T05:28:35.9001@ToddLehman - actually, it's not already golfed. I wrote it on one line because that's how I created it in the REPL, but I'm certain I could cut the length down significantly. – Glen O – 2015-08-23T05:32:59.890
@ToddLehman Close vote retracted. As code golf, this would have been more interesting with a time limit though. – Dennis – 2015-08-23T06:10:59.227
@Dennis — Time limit as in a deadline of submitting answers? – Todd Lehman – 2015-08-23T06:13:59.163
2Time limit as in program has to finish before the sun explodes. I don't think you should change it anymore though, as it would invalidate an existing answer. – Dennis – 2015-08-23T06:16:51.667