Skip to content

Instantly share code, notes, and snippets.

@enatividad
Created June 14, 2021 03:48
Show Gist options
  • Save enatividad/efcf3701e63f0bc391bc01cac45fe6a4 to your computer and use it in GitHub Desktop.
Save enatividad/efcf3701e63f0bc391bc01cac45fe6a4 to your computer and use it in GitHub Desktop.
FunBar (FizzBuzz) Program
def modulo_alternative!(target, tester)
while target.positive?
target -= tester
end
target.zero?
end
(1..100).each do |i|
if modulo_alternative!(i, 15)
puts 'FunBar'
elsif modulo_alternative!(i, 3)
puts 'Fun'
elsif modulo_alternative!(i, 5)
puts 'Bar'
else
puts i
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment