Skip to content

Instantly share code, notes, and snippets.

@ianmcnally
Created June 30, 2014 17:33
Show Gist options
  • Save ianmcnally/68878e2f5d762f7c2d01 to your computer and use it in GitHub Desktop.
Save ianmcnally/68878e2f5d762f7c2d01 to your computer and use it in GitHub Desktop.
Fizzbuzz
fizzbuzz = ->
for n in [1..100]
fizz = if n % 3 is 0 then 'fizz' else ''
buzz = if n % 5 is 0 then 'buzz' else ''
output = fizz + buzz or n
console.log output
def fizzbuzz():
for i in range(1, 101):
fizz = 'fizz' if (i % 3 == 0) else ''
buzz = 'buzz' if (i % 5 == 0) else ''
output = fizz + buzz or i
print output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment