Skip to content

Instantly share code, notes, and snippets.

@dhanji
Created April 13, 2017 02:33
Show Gist options
  • Save dhanji/831f45903c8490c8dd321da9db9b5d02 to your computer and use it in GitHub Desktop.
Save dhanji/831f45903c8490c8dd321da9db9b5d02 to your computer and use it in GitHub Desktop.
-- FizzBuzz: http://wiki.c2.com/?FizzBuzzTest
fizzbuzz x
| fizz x && buzz x = "FizzBuzz"
| fizz x = "Fizz"
| buzz x = "Buzz"
| otherwise = ""
where
fizz n = (n `mod` 3) == 0
buzz n = (n `mod` 5) == 0
main = putStrLn $ show $ map fizzbuzz [1..100]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment