Skip to content

Instantly share code, notes, and snippets.

@rosslebeau
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rosslebeau/72c571ed7b67f562a7d0 to your computer and use it in GitHub Desktop.
Save rosslebeau/72c571ed7b67f562a7d0 to your computer and use it in GitHub Desktop.
FizzBuzz in Ruby without conditionals or modulo
def fizzbuzzNoMod limit
i = 1.0
answers = [['fizzbuzzxx', 'buzzxx'], ['fizzxx', i]]
loop do
puts answers[(i / 5.0).ceil - (i / 5.0).floor][(i / 3.0).ceil - (i / 3.0).floor].to_s.chop.chop
i += 1.0
1/((limit + 1.0) - i).to_i
answers[1][1] = i
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment