Skip to content

Instantly share code, notes, and snippets.

@davidvandusen
Forked from kvirani/README.md
Created May 5, 2015 13:17
Show Gist options
  • Save davidvandusen/72546b75f9d29d5f835a to your computer and use it in GitHub Desktop.
Save davidvandusen/72546b75f9d29d5f835a to your computer and use it in GitHub Desktop.
1.upto(100) do |i|
if i % 5 == 0 && i % 3 == 0
puts "FizzBuzz"
elsif i % 5 == 0
puts "Buzz"
elsif i % 3 == 0
puts "Fizz"
else
puts i
end
end
@heavymetta
Copy link

def fizzbuzz_value(i)
if i % 5 == 0 && i % 3 == 0
"FizzBuzz"
elsif i % 5 == 0
"Buzz"
elsif i % 3 == 0
"Fizz"
else
i
end
end

def fizzbuzz (start, endval)
start.upto(endval) do |i|
puts fizzbuzz_value(i)
end
end

fizzbuzz(5, 55)

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