006-001-003

For Loop: Sum Calculator Program

Easy

Problem Description

For Loop: Sum Calculator Program

Learning Objective: Learn cumulative calculation using for loops

Create a program that calculates the sum from 1 to the input number.

Input

Line 1: End number (integer, 1 to 10)

Output

Sum from 1 to [end]: [sum]

Test Cases

※ Output examples follow programming industry standards

Input:
5
Expected Output:
Sum from 1 to 5: 15
Input:
10
Expected Output:
Sum from 1 to 10: 55
Input:
1
Expected Output:
Sum from 1 to 1: 1
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 9 free executions remaining