Sum to N
Lesson 9 of 32 in Coddy's Coding Problems course.
Challenge
EasyWrite 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
1Course Introduction
Introduction2Easy Difficulty
SumEven or OddSquare & CubeMonthsMiddle digitTriangleMathematicsSum to NSum of numbersSortingCircle