Friday, 23 September 2016

Factorial by Recursion

/* Factorial by Recursion */

#include<stdio.h>
int fact(int);

int main()
{
int n;
printf("Type any value : ");
scanf("%d",&n);
n=fact(n);
printf("\nFactorial : %d ",n);
return 0;
}

int fact(int x)
{
if(x==1)
return(x);
else
x=x*fact(x-1);
}

No comments:

Post a Comment

Featured post

Will AI Replace Programmers? The Truth Behind the Hype in 2025

Exploring the Future of Coding: Will AI Take Over Software Development or Enhance It?  Will AI Replace Programmers? The Truth Behind the Hyp...