Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Writing FizzBuzz without modulus division
fizz = [nil, nil, "Fizz"].cycle
buzz = [nil, nil, nil, nil, "Buzz"].cycle
numbers = 1..100, buzz) do |n, f, b|
fizzbuzz = [f, b].join
puts(fizzbuzz.empty? ? n : fizzbuzz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment