201k views
24 votes
Write a program named Total.java that accepts two numbers, N and M, then add all numbers in the range of [N, M], assume N<=M.

then display the total. Please use for loop for this problem.

1 Answer

3 votes

Answer:

hi how re

Step-by-step explanation:

Given a number a and limit N. Find the sum of multiple of a upto N. ... If zero then add i to sum(initially sum = 0). ... in O(1) time we can use the formula of summation of n natural numbers. ... a = 4 and N = 23, number of multiples of a, m = N/a(integer division). ... Find the sum of all multiples of 2 and 5 below N.

User Electrophanteau
by
4.6k points