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 &v, int n){

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!