Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Challenge: Chasing Knuth's Conjectureby hv (Prior) |
on Mar 29, 2005 at 15:07 UTC ( [id://443148]=note: print w/replies, xml ) | Need Help?? |
The code below finds 1..10 in 2 seconds on this machine, having calculated nothing greater than 201!; 1..37 takes 8s, and calculates 366!. Beyond that we start to find some more difficult, but at 37 mins and 24MB it has so far found all but 8 numbers (59, 64, 72, 86, 87, 92, 97, 99) out of 1..99. Update: still missing (92, 97, 99) after 274 mins (process size 67MB). The basic ideas are: a) keep a sorted list (@try) of the numbers we've reached but not yet calculated a factorial for; b) at each iteration, take the smallest untried number and find it's factorial, and repeatedly take the square root of the result until we get to a number we've seen before; c) use a binary chop to insert new pending numbers.
In the output, eg "5 => ssff" means that 5 = int(sqrt(int(sqrt(fact(fact(3)))))). Hugo
In Section
Meditations
|
|