Skip to content

Instantly share code, notes, and snippets.

@ngsw
Created August 13, 2012 14:03
Show Gist options
  • Select an option

  • Save ngsw/3341025 to your computer and use it in GitHub Desktop.

Select an option

Save ngsw/3341025 to your computer and use it in GitHub Desktop.
#!/bin/env ruby
#-*- coding: utf-8 -*-
def fizzbuzz(max)
step = 1
while step <= max
fizbuz = step % 15 == 0 ? "FizzBuzz" : \
step % 5 == 0 ? "Buzz" : \
step % 3 == 0 ? "Fizz" : step
yield fizbuz
step += 1
end
end
fizzbuzz(100){ |x| puts x }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment