Challenge: Sum of 1 to N

Lab C Beginner 10 points

Read a whole number n and print the sum 1 + 2 + ... + n.

Input

One integer n (1 ≤ n ≤ 10000).

Output

The sum.

Example

Input

5

Output

15
Sample input available Sample output available
Editor
C

Hints

Start total at 0 before the loop.

Loop i from 1 to n and add i each time.

Solution explanation

The loop visits every number from 1 to n and adds it to the running total.

Show solution
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int total = 0;
    for (int i = 1; i <= n; i++) {
        total += i;
    }
    printf("%d\n", total);
    return 0;
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD