[Answered] Write a function sumOfMultiples, that inputs two integers – seed and cap. The function should return the sum of all

Write a function sumOfMultiples, that inputs two integers – seed and cap. The function should return the sum of all the multiples of seed present between 1 and cap (both inclusive). Your function should be named sumOfMultiples. Your function has two parameters in the order: seed: integer argument whose multiples need to be summed. cap: integer argument indicating the upper limit of the multiples to be added. Your function should return the sum of the multiples: an integer value. Your function should not print/output anything Examples: For the input arguments sumOfMultiples(6, 20), the function should return 36. (Explanation: the multiples of 6 between 1 and 20 are 6, 12 and 18. The sum of these multiples is 36). For the input arguments sumOfMultiples(1, 3), the function should return 6. (Explanation: the multiples of 1 between 1 and 3 are 1, 2 and 3. The sum of these multiples is 6).

CategoriesUncategorized

Leave a Reply

Your email address will not be published.