fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int num, i;
  5. unsigned long long factorial = 1;
  6.  
  7. // Get the input from the user
  8. printf("Enter a number: ");
  9. scanf("%d", &num);
  10.  
  11. // Check if the number is negative, zero, or positive
  12. if (num < 0) {
  13. printf("Factorial does not exist for negative numbers\n");
  14. } else {
  15. for (i = 1; i <= num; i++) {
  16. factorial *= i;
  17. }
  18. printf("The factorial of %d is %llu\n", num, factorial);
  19. }
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Enter a number: The factorial of 32764 is 0