From f1e442c1b3c4696e178910c32f36d1b3d1fc4472 Mon Sep 17 00:00:00 2001 From: jdmcdona Date: Tue, 15 Sep 2015 17:28:25 -0500 Subject: [PATCH] Add solution for problem 65. --- Problem065.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Problem065.hs diff --git a/Problem065.hs b/Problem065.hs new file mode 100644 index 0000000..25760c0 --- /dev/null +++ b/Problem065.hs @@ -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