Created
November 23, 2015 13:05
-
-
Save chuck0523/dbfa4ab55811e82eaaf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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