Question: Write a function int sumMultiples(const vector &nums, int n) that returns the sum of all multiples of values in the vector nums less than n.
Write a function int sumMultiples(const vector &nums, int n) that returns the sum of all multiples of values in the vector nums less than n. For example, vector nums = {3, 5}; int n = 30; sumMultiples(nums, n); should return 195. In particular, 195 = 3+5+6+9+10+12+15+18+20+21+24+25+27. Assume that the elements of nums are positive integers.
int sumMultiples(const vector
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
