Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Last active October 1, 2016 15:51
Show Gist options
  • Save utgwkk/32bb3bb427a8d7671984fa4bf0a167ce to your computer and use it in GitHub Desktop.
Save utgwkk/32bb3bb427a8d7671984fa4bf0a167ce to your computer and use it in GitHub Desktop.
FizzBuzz in Haskell
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