Skip to content

Instantly share code, notes, and snippets.

@DiegoSalazar
Created July 15, 2013 18:47
Show Gist options
  • Select an option

  • Save DiegoSalazar/79442b91940f2ae866cd to your computer and use it in GitHub Desktop.

Select an option

Save DiegoSalazar/79442b91940f2ae866cd to your computer and use it in GitHub Desktop.
# 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