31
Almost equivalent to Project Euler's first question:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Challenge:
Given a positive integer N
and a set of at least one positive integer A
, output the sum of all positive integers less than N
that are multiples of at least one member of A
.
For example, for the Project Euler case, the input would be:
1000
3
5
Test cases:
Input : 50, [2]
Output: 600
Input : 10, [3, 5]
Output: 23
Input : 28, [4, 2]
Output: 182
Input : 19, [7, 5]
Output: 51
Input : 50, [2, 3, 5]
Output: 857
4>
3Can you give some test cases? Obviously don't post the answer to the PE one, but what about other examples? – Rɪᴋᴇʀ – 2016-12-19T03:55:03.250
1@WheatWizard: The word "or" implies that each number is counted only once, at most. I agree that the question needs to make it clear how many "numbers to check for multiples of" arguments must be supported, though. Exactly two? One or more? Zero or more? – smls – 2016-12-19T03:58:29.693
1Can we take "numbers equal to or below 10", or take 9 as input instead of 10? – Stewie Griffin – 2016-12-19T07:41:44.117
"and a set of at least one positive integer A" how big can the set be? – betseg – 2016-12-19T07:41:54.890