Skip to content

Instantly share code, notes, and snippets.

@wontwon
Created April 21, 2016 08:45
Show Gist options
  • Save wontwon/64426dab72bc428aa999b51bc000c1e6 to your computer and use it in GitHub Desktop.
Save wontwon/64426dab72bc428aa999b51bc000c1e6 to your computer and use it in GitHub Desktop.
Check it
def check_less_than_max_nums(max)
less_than_max_num_array = []
(0..(max-1)).each do |i|
less_than_max_num_array.push(i)
end
return less_than_max_num_array
end
def check_divisible_by_three_five (numbers)
divisible_numbers = []
numbers.each do |i|
if((i % 3 === 0) || (i % 5 === 0)) #AND ARE divisible by either three or five
if((i % 5 === 0) && (i % 3 === 0)) #BUT ARE NOT divisible by _both_ three and five
divisible_numbers.push(i)
end
end
end
return divisible_numbers
end
def crazy_nums(max)
less_than_max_nums = check_less_than_max_nums(max) numbers #ARE less than max
divisible_by_three_five_nums = check_divisible_by_three_five(less_than_max_nums)
puts divisible_by_three_five_nums.sort #You should return the result in increasing order.
end
crazy_nums(1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment