Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created November 23, 2015 13:05
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 chuck0523/dbfa4ab55811e82eaaf0 to your computer and use it in GitHub Desktop.
Save chuck0523/dbfa4ab55811e82eaaf0 to your computer and use it in GitHub Desktop.
import Control.Monad
main = do
putStrLn "数字を入力"
numStr <- getLine -- 文字列として数値を受け取る
let num = read numStr -- `read`は文字列を数値に変換する関数
showNums num
showNums num = do
forM_ [1..num] $ \i ->
putStrLn (show i ++ " : " ++ judgeNum i)
judgeNum i =
case mod i 15 of
0 -> "FizzBuzz"
3 -> "Fizz"
5 -> "Buzz"
6 -> "Fizz"
9 -> "Fizz"
10 -> "Buzz"
12 -> "Fizz"
_ -> ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment