fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int n;
  5. printf("Enter the number: ");
  6. scanf("%d",&n);
  7. int factorial=1;
  8. for(int i=1;i<=n;i++){
  9. factorial=factorial*i;
  10. }
  11. printf("Answer is %d",factorial);
  12.  
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0s 5316KB
stdin
3
stdout
Enter the number: Answer is 6