-- It is possible to show that the square root of two can be expressed as an infinite continued fraction. -- -- √ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... -- -- In the first one-thousand expansions, how many fractions contain a numerator with more digits than denominator? import Euler import Data.Ratio nDigits 0 = 0 nDigits n = 1 + nDigits (n `div` 10) iterations = iterate (\x -> 1+1/(1+x)) (3%2) main = print $ length $ filter (\x -> nDigits (numerator x) > nDigits (denominator x)) $ take 1000 iterations