Sum of First N Numbers (input)
easyQuestion 289Read a single integer n from standard input, then use a loop to add up the numbers from 1 to n. Print the result in the exact format shown in Expected Output.
For the input 5, the sum 1+2+3+4+5 is 15, so the program prints Sum: 15.
Expected output
Sum: 15= newline. The output ends with a newline, so print one after the last line.
Hints3 available
Sign in to use hintsTopics
Loops
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.