Skip to content

Instantly share code, notes, and snippets.

@zmaupin
Created October 16, 2018 02:53
Show Gist options
  • Select an option

  • Save zmaupin/43263726f03ce9cd4a84ffcb33fce5d8 to your computer and use it in GitHub Desktop.

Select an option

Save zmaupin/43263726f03ce9cd4a84ffcb33fce5d8 to your computer and use it in GitHub Desktop.
def multiples?(first_number, second_number, limit)
i = 1
multiples = []
while i < limit
multiples << i if i % first_number == 0 || i % second_number == 0
i += 1
end
# p "multiples of: #{number} - up to: #{limit}"
multiples
end
def sum_of_array(my_array)
i = 0
j = 0
while j < my_array.size
i += my_array[j]
j += 1
end
i
end
def run(first_number, second_number, limit)
multiples = multiples?(first_number, second_number, limit)
sum = sum_of_array(multiples)
puts sum
end
run(3, 5, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment