Last active
July 24, 2018 14:03
-
-
Save Epyon616/99bd3f92d011a06a5e0d to your computer and use it in GitHub Desktop.
Decided to see if I could solve the age old fizz buzz test, it's probably not the most concise solution and its definitely not finished but it is at least readable
This file contains hidden or 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
#!/usr/bin/env ruby | |
number_array = [*1..100] | |
def divisible_by(divisible, number) | |
number.modulo(divisible).zero? | |
end | |
number_array.each do |num| | |
puts "fizz buzz" if (divisible_by(3, num) && divisible_by(5, num)) | |
puts "buzz" if divisible_by(3, num) | |
puts "fizz" if divisible_by(5, num) | |
puts num if (!divisible_by(3, num) && !divisible_by(5, num)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment