Sum of first N natural numbers
Submit solution
C
Points:
10 (partial)
Time limit:
8.0s
Memory limit:
64M
Author:
Problem type
Allowed languages
Problem statement
Given a positive integer N as input, print the sum of first N natural numbers.When N is less than or equal to 0, 0 should be printed.
Sample Input
5
Sample Output
15
Explanation
Sum of first 5 natural numbers 1+2+3+4+5=15
Comments
include<stdio.h>
int main() { int sum=0,i=5; while(i<=5) { sum=sum+1; } printf("%d",sum); }