Thursday, June 27, 2013

Write a recursive function to find factorial of a number.



long fact(int n)
{ if(n<0)
     printf(“Invalid input”);
 else if(n==0)
     return 1;
else
    return(n*fact(n-1));
}

No comments:

Post a Comment