0
Java program that will add the numbers from starting to ending using only scanner.
For example, the starting inputted is 5 and the ending is 10. The numbers from 5 to 10 should be add, 5+6+7+8+9+10=45. If the starting is 2 and ending is 9, → 2+3+4+5+6+7+8+9=44 If starting is 1 and ending is 5, → 1+2+3+4+5=15 What is the formula of this problem? https://code.sololearn.com/cCKw929Z8Gee/?ref=app
1 Odpowiedź
+ 2
Algoritm:
1) create zero variable, our answer
2) two inputs, n and m
2) for each number in range from n till m add every number to our variable
3) return variable