factorial of a number

#include<stdio.h>
 long int multiply(int n);
int main()
{
    int n;
    scanf("%d",&n);
    printf("factoraial of %d is %d",n,multiply(n));
    return 0;
}
long int multiply(int n)
{
    if(n>=1)
    return n*multiply(n-1);
    else
    return 1;
}
input:
5
output:
factoraial of 5 is 120

No comments:

Post a Comment