โ Back to Loops
Question 289
Sum of First N Numbers (input)
Sum of First N Numbers (input)
Read a single integernfrom standard input, then use a loop to add up the numbers from1ton. Print the result in the format: Sum: 15 For the input5, the sum1+2+3+4+5is15, so the program printsSum: 15.
Expected Output:
Sum: 15
Topics:
Loops
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.