Skip to content

Instantly share code, notes, and snippets.

@programmingfaster0226
Created January 18, 2018 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save programmingfaster0226/053b0939adc49ed391b183b448a39718 to your computer and use it in GitHub Desktop.
Save programmingfaster0226/053b0939adc49ed391b183b448a39718 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<conio.h>
int sum(int);
void main()
{
int s;
s=sum(50);
printf("the sum of first 50 natural numbers is %d",s);
getch();
}
int sum(int x)
{
if (x<1)
return 0;
else
return (x+sum(x-1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment