-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path74.hs
More file actions
25 lines (18 loc) · 640 Bytes
/
74.hs
File metadata and controls
25 lines (18 loc) · 640 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Data.List
import System.IO.Unsafe
import Common
factorial n = product [2..n]
facSum :: Integer -> Integer
facSum n = sum $ map factorial (digitsBaseN 10 n)
chainSize f l ls n = let n' = f n
p = elem n' l
in case p of
False -> chainSize f (n' : l) (ls + 1) n'
True -> ls
facChainSize = chainSize facSum [] 0
answers = filter (\x -> seq (debug x) $ facChainSize x == 59) [1..1000000]
debug x = unsafePerformIO $
if x `mod` 100000 == 0 then (print x) else return ()
main = do
print answers
print (length answers)