Created
July 15, 2013 18:47
-
-
Save DiegoSalazar/79442b91940f2ae866cd to your computer and use it in GitHub Desktop.
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
| # A program that takes any single number (max) and returns all the numbers below (max) that are divisible by five or two but not by both five and two. | |
| def mini_fizzbuzz(max) | |
| s = [] | |
| max.downto 0 do |i| | |
| s << i if (i % 2 == 0 || i % 5 == 0) && !(i % 2 == 0 && i % 5 == 0) | |
| end | |
| s | |
| end | |
| p mini_fizzbuzz(50) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment