Skip to content

Instantly share code, notes, and snippets.

@LieutenantChips
Created September 25, 2017 21:19
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 LieutenantChips/a9434c7d17ea11057ae1f9c3e4d52614 to your computer and use it in GitHub Desktop.
Save LieutenantChips/a9434c7d17ea11057ae1f9c3e4d52614 to your computer and use it in GitHub Desktop.
--ghc 7.10
f :: Integer -> Integer
f 0 = 1
f 1 = 1
f n = f (n-1) + f (n-2)
--I just google searched this.
isPrime :: Integer->Bool
isPrime x = null [y | y<-[2..floor (sqrt (fromIntegral x))], x `mod` y == 0]
result :: Integer -> String
result n | (n `mod` 15 == 0) = "FizzBuzz"
| (n `mod` 5 == 0) = "Fizz"
| (n `mod` 3 == 0) = "Buzz"
| (isPrime (n) == True) = "BuzzFizz"
| otherwise = show n
main = print $ result (f 100) --NUMBER HERE INSTEAD OF THE "100"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment