Last active
October 1, 2016 15:51
-
-
Save utgwkk/32bb3bb427a8d7671984fa4bf0a167ce 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
| fizzbuzzStr n | |
| | n `mod` 15 == 0 = "FizzBuzz" | |
| | n `mod` 5 == 0 = "Buzz" | |
| | n `mod` 3 == 0 = "Fizz" | |
| | otherwise = show n | |
| main = do | |
| s <- getLine | |
| let n = read s :: Int | |
| mapM putStrLn $ fizzbuzz n | |
| where | |
| fizzbuzz n = map fizzbuzzStr [1 .. n] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment