Skip to content

Instantly share code, notes, and snippets.

@tstone
Created November 2, 2009 01:18
Show Gist options
  • Save tstone/223841 to your computer and use it in GitHub Desktop.
Save tstone/223841 to your computer and use it in GitHub Desktop.
Recursive FizzBuzz Ruby
def fizzbuzz(start, ending)
if (start % 15 == 0)
puts 'Fizzbuzz'
elsif (start % 5 == 0)
puts 'Buzz'
elsif (start % 3 == 0)
puts 'Fizz'
else
puts start
end
if start < ending
fizzbuzz(start+1, ending)
end
end
fizzbuzz(1, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment