JavaScript: Sum of oddly divisible numbers from a range
JavaScript Math: Exercise-89 with Solution
Oddly Divisible Sum in Range
Write a JavaScript program that takes three arguments x, y, n and calculates the sum of the numbers oddly divided by n from the range x, y inclusive.
Test Data:
(1,5,3) -> 3
(100, 1000, 5) -> 99550
Sample Solution:
JavaScript Code:
Output:
Range: 1-5 Divisible number: 3 Sum of oddly divisible numbers from a the said range: 3 Range: 100-1000 Divisible number: 5 Sum of oddly divisible numbers from a the said range: 99550
Flowchart:

Live Demo:
For more Practice: Solve these Related Problems:
- Write a JavaScript function that sums numbers in a range that, when divided by a given divisor, yield an odd remainder.
- Write a JavaScript function that filters numbers within a range based on an odd remainder criterion and then computes their sum.
- Write a JavaScript function that iterates through a numerical range, checks for odd divisibility, and accumulates the total.
- Write a JavaScript function that validates the range and divisor before calculating the sum of oddly divisible numbers.
Improve this sample solution and post your code through Disqus.
Previous: Check to given vectors are orthogonal or not.
Next: Test if a number is a Harshad Number or not.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics