Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@purcell
Created October 30, 2014 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purcell/991605f16bd08f2cc4a0 to your computer and use it in GitHub Desktop.
Save purcell/991605f16bd08f2cc4a0 to your computer and use it in GitHub Desktop.
fizzbuzz
module FizzBuzz where
fizzbuzz :: (Show a, Integral a) => a -> String
fizzbuzz n = case (n `rem` 3, n `rem` 5) of
(0, 0) -> "FizzBuzz"
(0, _) -> "Fizz"
(_, 0) -> "Buzz"
_ -> show n
main = mapM_ (putStrLn . fizzbuzz) [1..50]
@purcell
Copy link
Author

purcell commented Oct 30, 2014

This simplest-thing-that-could-possibly-work code is most likely how I'd actually solve fizzbuzz in haskell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment