Factorial program in c using recursion
#include <stdio.h>
#include <stdlib.h>
#define b 10
int main()
{
const int a=0;
int facto;
if(a<=0)
{
printf("error a value should be more then 0");
}
else
{
facto = factorial(a);
printf("factoria of %d is %d\n",a,facto);
}
return 0;
}
int factorial(int k)
{
if(k<=1)
{
return 1;
}
k=k * factorial(k-1);
return k;
}
Comments