Skip to content

Instantly share code, notes, and snippets.

@yuya-takeyama
Created October 9, 2011 09:37
Show Gist options
  • Save yuya-takeyama/1273502 to your computer and use it in GitHub Desktop.
Save yuya-takeyama/1273502 to your computer and use it in GitHub Desktop.
FizzBuzz in Haskell.
-- Thanks to @VoQn
main = mapM_ (putStrLn . fizzbuzz)[1..100]
where
fizzbuzz x | x `mod` 15 == 0 = "FizzBuzz"
| x `mod` 5 == 0 = "Buzz"
| x `mod` 3 == 0 = "Fizz"
| otherwise = show x
-- Thanks to @masa_edw
main = mapM_ putStrLn $ fizzbuzzList 100
where
fizzbuzzList x = [fizzbuzz x | x <- [1..x]]
where
fizzbuzz x | x `mod` 15 == 0 = "FizzBuzz"
| x `mod` 5 == 0 = "Buzz"
| x `mod` 3 == 0 = "Fizz"
| otherwise = show x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment