fork download
  1. #include<stdio.h>
  2.  
  3. int rev_fact(int n)
  4. {
  5. if(n<1)
  6. return -1;
  7. if(n==0)
  8. return 1;
  9. int f=1, i=1;
  10. while(f<n){
  11. i++;
  12. f*=i;
  13. }
  14. if(f==n)
  15. return i;
  16. return -1;
  17.  
  18. }
  19. int main(int argc, char const *argv[])
  20. {
  21. int x;
  22. printf("Please give x");
  23. scanf("%d",&x);
  24. if(rev_fact(x)==-1)
  25. printf("No factorial is equal to %d",x);
  26. else
  27. printf("%d!=%d",rev_fact(x),x);
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
Please give xNo factorial is equal to 0