fork download
  1. #include <stdio.h>
  2. long int factorial(int n){
  3. if(n==0||n==1)
  4. return 1;
  5. else
  6. return n*factorial (n-1);
  7. }
  8.  
  9.  
  10. int main(void) {
  11. int n;
  12. printf("enter a number:");
  13. scanf("%d",&n);
  14. printf("factorial of %d is %ld",n,factorial(n));
  15.  
  16. // your code goes here
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 5328KB
stdin
Standard input is empty
stdout
enter a number:factorial of 32765 is 0