Last active
August 29, 2015 14:04
-
-
Save takahiro47/dd51d40e9d67daeb0a8e to your computer and use it in GitHub Desktop.
FizzBuzz.coffee
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
# 2014/08/01 11:44:01 | |
# | |
# Run: | |
# $ coffee main.coffee | |
# | |
# Question: "FizzBuzz問題" | |
# http://d.hatena.ne.jp/keyword/Fizz-Buzz%CC%E4%C2%EA | |
# を解くプログラムを作成し、GitHub, Gist, 個人Webページなどにアップして下さい。 | |
## Solution 1 | |
for i in [1..100] | |
if not (i % 15) | |
console.log 'FizzBuzz' | |
else if not (i % 3) | |
console.log 'Fizz' | |
else if not (i % 5) | |
console.log 'Buzz' | |
else | |
console.log i | |
## Solution 2 | |
[1..100].map (i) -> console.log "#{if not(i%15) then 'FizzBuzz' else if not(i%3) then 'Fizz' else if not(i%5) then 'Buzz' else i}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment