1
0
Fork 0

Length is indexed by 1, start counts there

main
Bill Ewanick 2023-10-20 02:21:40 -04:00
parent 956e56028f
commit a3dda37643
1 changed files with 4 additions and 5 deletions

View File

@ -7,7 +7,7 @@ import Control.Monad ()
import Debug.Trace (trace)
f' :: Integer -> Integer
f' n = f'' 0 n
f' n = f'' 1 n
where
f'' :: Integer -> Integer -> Integer
f'' i n'
@ -19,14 +19,13 @@ f' n = f'' 0 n
t'' = trace "\n#######################################################\n"
f :: Integer -> Integer
f n = s 0 n
f n = s 1 n
where
s :: Integer -> Integer -> Integer
s i n
| n == 1 = i
| even n = s i' (n `div` 2)
| odd n = s i' (3*n + 1)
where i' = succ i
| even n = s (succ i) (n `div` 2)
| odd n = s (succ i) (3*n + 1)
main :: IO ()
main = print $ map f [2^361..]