Add solution for problem 65.

This commit is contained in:
jdmcdona 2015-09-15 17:28:25 -05:00
parent 5a172a158e
commit f1e442c1b3
1 changed files with 10 additions and 0 deletions

10
Problem065.hs Normal file
View File

@ -0,0 +1,10 @@
-- 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