Question: Write a static method named sumDivisibleBy that takes three int arguments, and returns an int. The first two argument values are a starting value and

Write a static method named sumDivisibleBy that takes three int arguments, and returns an int. The first two argument values are a starting value and an ending value (you may safely assume that the start value will always be less than or equal to the end value). The third argument is a divisor (you may safely assume that the divisor will always be a positive value). The function should compute and return the sum of all integers between the start value and the end value that are evenly divisible by the divisor value. The star value and the end value should be included in the sum if they are also evenly divisible by the divisor. Examples: sumDivisibleBy(1, 2, 3) will return 0 (No numbers between 1 and 2 are divisible by 3) sumDivisibleBy(1, 10, 3) will return 18 (3 + 6 + 9 = 18) sumDivisibleBy(3, 9, 3) will return 18 sumDivisibleBy(2, 10, 3) will return 18 sumDivisibleBy(1, 9, 2) will return 20 (2 + 4 + 6 + 8 = 20) sumDivisibleBy(2, 10, 5) will return 15 (5 + 10 = 15)

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!