fork download
  1. // Online C compiler to run C program online
  2. #include <stdio.h>
  3.  
  4. int main() {
  5. int n;
  6. printf("enter the value of n\n");
  7. scanf("%d",&n);
  8. printf("Factorial of %d=%ld",n,fact(n));
  9. return 0;
  10. }
  11. long int fact(int n)
  12. {
  13. if (n==1)
  14. return 1;
  15. else
  16. return n*fact(n-1);
  17. }
Success #stdin #stdout 0.02s 25780KB
stdin
Standard input is empty
stdout
// Online C compiler to run C program online
#include <stdio.h>

int main() {
int n;
printf("enter the value of n\n");
scanf("%d",&n);
printf("Factorial of %d=%ld",n,fact(n));
    return 0;
}
long int fact(int n)
{
    if (n==1)
    return 1;
    else
    return n*fact(n-1);
}