Skip to content

Instantly share code, notes, and snippets.

@takahiro47
Last active August 29, 2015 14:04
Show Gist options
  • Save takahiro47/dd51d40e9d67daeb0a8e to your computer and use it in GitHub Desktop.
Save takahiro47/dd51d40e9d67daeb0a8e to your computer and use it in GitHub Desktop.
FizzBuzz.coffee
# 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