I am trying to calculate factorial using recursion but my program is retuing wrong value. I am unable to understand the recursion functionality. Please help me in understanding how recursion works. My code is as follows:
#include <stdio.h>
#include <math.h>
int main() {
//code
int T,N,sol;
scanf("%dn",&T);
while(T--)
{
scanf("%dn",&N);
sol=fact(N);
printf("%dn",sol);
}
retu 0;
}
int fact(int n)
{
int value;
while(n>0)
{
value=n*fact(n-1);
n=n-1;
}
retu value;
}
