For Euler 25; What is the first term in the Fibonacci sequence to contain 1000 digits?; the following seems to work.
-- For number of digits being 5 or more.
fibNdigits :: Int -> Int
fibNdigits nDigits = floor (((fromIntegral nDigits) - 1.0) / (logBase
10 phi)) + 2
where
sq5 = sqrt 5 :: Double
phi = (1 + sq5) / 2
--
--
Regards,
KC
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
