Created
October 16, 2018 02:53
-
-
Save zmaupin/43263726f03ce9cd4a84ffcb33fce5d8 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
| 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