Skip to content

Instantly share code, notes, and snippets.

@janv
Created February 4, 2013 11:26
Show Gist options
  • Save janv/4706223 to your computer and use it in GitHub Desktop.
Save janv/4706223 to your computer and use it in GitHub Desktop.
main = do sequence_ (map (putStr . (++ "\n")) (fizzbuzz 100))
fizzbuzz upper = [stringify x | x <- [1..upper]]
where stringify n
| n `divisibleBy` 15 = "fizzbuzz"
| n `divisibleBy` 3 = "fizz"
| n `divisibleBy` 5 = "buzz"
| otherwise = show n
divisibleBy dividend divisor = dividend `mod` divisor == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment