https://wiki.haskell.org/index.php?title=Talk:Euler_problems/11_to_20&feed=atom&action=historyTalk:Euler problems/11 to 20 - Revision history2020-01-22T15:02:03ZRevision history for this page on the wikiMediaWiki 1.27.4https://wiki.haskell.org/index.php?title=Talk:Euler_problems/11_to_20&diff=33403&oldid=prevKapil: Improvement to solution to Collatz problem in ProjectEuler2010-01-31T14:14:35Z<p>Improvement to solution to Collatz problem in ProjectEuler</p>
<p><b>New page</b></p><div>It seems to me that the solution posted to the Collatz problem is not<br />
the most efficient. In order to find integer that gives the longest chain<br />
it is not necessary to _find_ that longest chain. So one needs to use<br />
a Boolean function that merely checks whether the chain for n is<br />
longer than that for m where m is the winner so far.<br />
<br />
This does not need to repeatedly calculate the chain for m if we <br />
the tuple (m,c,m') where c is the length of the chain from m to m'<br />
which we have calculated so far.<br />
<br />
As far as I know the longest chain is significantly longer than all<br />
the other chains considered so this should save us a lot of time by<br />
avoiding computing that chain.</div>Kapil