Skip to content

Instantly share code, notes, and snippets.

@yashigani
Created October 15, 2013 11:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yashigani/6990106 to your computer and use it in GitHub Desktop.
Save yashigani/6990106 to your computer and use it in GitHub Desktop.
import System.Environment (getArgs)
main = do
(x:_) <- getArgs
mapM_ putStrLn $ createFizzBuzz $ read x
createFizzBuzz :: Int -> [String]
createFizzBuzz 0 = []
createFizzBuzz x = map fizzbuzz [1..x]
fizzbuzz :: Int -> String
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