11 lines
343 B
Haskell
11 lines
343 B
Haskell
-- Find the sum of digits in the numerator of the 100th convergent of the continued fraction for e.
|
|
import Euler
|
|
|
|
convergent n = go $ take n e_cf
|
|
where
|
|
go [a] = a
|
|
go (a:as) = a + recip (go as)
|
|
e_cf = 2 : concatMap (\k -> [1, 2*k, 1]) [1..]
|
|
|
|
main = print $ sum $ (\x->x::[Integer]) $ toDigits $ numerator $ convergent 100
|