Created
June 14, 2021 03:48
-
-
Save enatividad/efcf3701e63f0bc391bc01cac45fe6a4 to your computer and use it in GitHub Desktop.
FunBar (FizzBuzz) Program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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