Skip to content

Instantly share code, notes, and snippets.

@zwass
Created September 16, 2012 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zwass/3732941 to your computer and use it in GitHub Desktop.
Save zwass/3732941 to your computer and use it in GitHub Desktop.
Haskell Fibonacci Prime Finder
squareRoot :: Integer -> Integer
squareRoot = floor . sqrt . (fromIntegral :: Integer -> Double)
isPrime :: Integer -> Bool
isPrime 1 = False
isPrime x = testDown x (squareRoot x) where
testDown a 1 = True
testDown a n
| a `mod` n == 0 = False
| otherwise = testDown a (n-1)
fib :: [Integer]
fib = seededFib 1 1 where
seededFib n n1 = n : seededFib n1 (n + n1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment