|
|
|
|
|
by throwaway81523
222 days ago
|
|
I just did a dumb search with lazy lists in Haskell, inspired by the famous problem about Hamming numbers. Runtime was 0.02 seconds. About 2 more seconds to fine the one after that (results: [1,40755,1533776805,57722156241751]). import Data.Ord
tri n = n*(n+1)`quot`2
pent n = n*(3*n-1)`quot`2
hex n = n*(2*n-1)
fs :: (Integer -> Integer)->[Integer]
fs f = map f [1..]
cm aas@(a:as) bbs@(b:bs)
= case compare a b of
EQ -> a : cm as bs
GT -> cm aas bs
LT -> cm as bbs
tt = (fs tri) `cm` (fs pent) `cm` (fs hex)
main = print . take 3 $ tt
Added: the one after that is 2172315626468283465 which took about 6 minutes with the same Haskell program. I'm sure there are faster implementations and better algorithms. I didn't try to search any further. |
|