Skip to content

Instantly share code, notes, and snippets.

@purcell purcell/FizzBuzz.hs

Created Oct 30, 2014
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.