And using dynamic precision :

http://haskell.org/haskellwiki/Applications_and_libraries/Mathematics#Dynamic_precision

The ERA package (darcs get http://darcs.augustsson.net/Darcs/CReal/) one can do better...

import CReal

even_fibs'' :: (Integral t) => [t]
even_fibs'' = iterate (\x -> round(fromIntegral x * (dp**3))) 2
  where dp :: CReal
        dp = phi


even_fibs_2 = filter even fibs
  where fibs = 1 : 1 : zipWith (+) (fibs) (tail fibs)

z n = take n $ zipWith (\a b -> (a==b,a)) even_fibs'' even_fibs_2

t z = not $ null $ filter fst $ z

main = let y = z 1000
       in putStr . unlines . map show $ y

This works quite well....

(True,2)
(True,8)
(True,34)
(True,144)
(True,610)
(True,2584)
(True,10946)
(True,46368)

...snip...

(True,3987795824799770715342824788687062628452272409956636682999616408)
(True,16892574194241670428824570378554538679120491007541580961500624834)
(True,71558092601766452430641106302905217344934236440122960529002115744)

...
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to