005-001-003
Loops: Number Sum
Medium
Problem Description
In this problem, you will create a program that reads a positive integer N from standard input, calculates the sum of all integers from 1 to N, and displays the result to standard output.
Problem Overview
Create a program that inputs a positive integer N and calculates the sum from 1 to N.
Input Format
Receive 1 line of input:
- Positive integer N (1 or greater)
Output Format
Output in the following format:
Sum from 1 to [N]: [sum]
Example
Input: 5
Output: Sum from 1 to 5: 15
(Calculation: 1+2+3+4+5=15)
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up