Last active
August 31, 2016 04:50
-
-
Save thejsj/e8f0a25f86f6502dd809e071b20f6e71 to your computer and use it in GitHub Desktop.
FizzBuzz in Haskell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fizzbuzz :: Int -> String | |
fizzbuzz x | mod x 15 == 0 = "fizzbuzz" | |
| mod x 5 == 0 = "fizz" | |
| mod x 3 == 0 = "buzz" | |
| otherwise = show x | |
printAll [] = return () | |
printAll (x:xs) = putStrLn x >> printAll xs | |
main = do | |
print "Number of lines:" | |
numStr <- getLine | |
let num = read numStr :: Int | |
printAll $ map fizzbuzz [0..num] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment