Skip to content

Instantly share code, notes, and snippets.

@octosteve
Created November 22, 2011 05:13
Show Gist options
  • Save octosteve/1384946 to your computer and use it in GitHub Desktop.
Save octosteve/1384946 to your computer and use it in GitHub Desktop.
FizzBuzz
1.upto(100) do |num|
if num % 3 == 0 || num % 5 == 0
if num % 3 == 0
print "Fizz"
end
if num % 5 == 0
print "Buzz"
end
else
print num
end
puts
end
@hamin
Copy link

hamin commented Nov 23, 2011

this was my fizzbuzz...though there were some way crazier ones: https://gist.github.com/1383759

here it is..its a one-liner :)

def fizzbuzz(n)n%15==0?"FizzBuzz": n%5==0?"Buzz": n%3==0?"Fizz": n.to_s end

@octosteve
Copy link
Author

Nice! I didn't think to check for '15'... where's your print statements?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment