I want to determine n successive integer numbers where the value of n is taken from an input box that means taken from user input. How can I write the code. Please give a solution. Advanced Thanks.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (3)
if you want to get the sum of n successive numbers, say 1,2,3,4,5,6 here n=6 then you can return (n)(n+1)/2 which in this case will be 21.
Say you want to get the sum of n numbers starting from the number a and ending at b, and the count of numbers is n, then you can do (a+b)(n)/2,
for example, 5,6,7,8,9 will give (5)(5+9)/2
I have seen your comment but I don't want to understand that actually I wanted the JavaScript code where the use give the value of n through the browser using an input box.