Skip to content

Instantly share code, notes, and snippets.

@dsomel21
Created June 17, 2016 05:08
Show Gist options
  • Select an option

  • Save dsomel21/71d235d1f574074aefefe6e88e10cd77 to your computer and use it in GitHub Desktop.

Select an option

Save dsomel21/71d235d1f574074aefefe6e88e10cd77 to your computer and use it in GitHub Desktop.
The Classic Fizz Buzz! But with a twist!
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 (starting, ending)
starting.upto(ending) {|i| puts fizzbuzz_value(i)}
end
fizzbuzz(1, 31)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment