fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int n, i;
  5. long long fact = 1;
  6.  
  7. printf("Enter a positive integer: ");
  8. scanf("%d", &n);
  9.  
  10. for(i = n; i >= 1; i--) {
  11. fact *= i;
  12. }
  13.  
  14. printf("Factorial of %d is %lld\n", n, fact);
  15. return 0;
  16. }
Success #stdin #stdout 0.03s 26080KB
stdin
Standard input is empty
stdout
#include <stdio.h>

int main() {
    int n, i;
    long long fact = 1;

    printf("Enter a positive integer: ");
    scanf("%d", &n);

    for(i = n; i >= 1; i--) {
        fact *= i;
    }

    printf("Factorial of %d is %lld\n", n, fact);
    return 0;
}