Sum of Natural Numbers


Submit solution

Points: 5 (partial)
Time limit: 8.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C

Problem Statement

Given an integer N, find the sum of natural numbers till N

Sample Input

5

Sample Output

15


Comments


  • 0
    24kayush  commented on May 4, 2023, 3:12 p.m.

    include<stdio.h>

    include<conio.h>

    int main() { int n,i,sum=0; printf("Enter the range : "); scanf("%d",&n); for(int i=1; i<=n; i++) { sum += i; } printf("The sum is : %d",sum); return 0; }


  • 0
    CIE22035  commented on April 13, 2023, 3:16 p.m.

    include<stdio.h>

    int main() { int i,n,sum=0; scanf("%d",&n); for(i=0;i<=n;i++) { sum=sum+i; } printf("%d",sum);

    return 0;
    }