Menu
Coddy logo textTech

Sum to N

Lesson 9 of 32 in Coddy's Coding Problems course.

challenge icon

Challenge

Easy

Write a program that gets a natural number N from input and outputs the sum of the first N natural numbers:
1 + 2 +3 + 4 + ... + N

 

Input
4

Output
10

Input
23

Output
276

Try it yourself

#include <stdio.h>

int main() {
    // Write code here
    return 0;
}

All lessons in Coding Problems