fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. unsigned long long fact = 1; // 階乗を格納する変数
  5.  
  6. for (int i = 1; i <= 20; i++) {
  7. fact *= i; // 階乗の計算
  8. printf("%2d! = %ld\n", i, fact);
  9. }
  10.  
  11. return 0;
  12. }
  13.  
  14.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
 1! = 1
 2! = 2
 3! = 6
 4! = 24
 5! = 120
 6! = 720
 7! = 5040
 8! = 40320
 9! = 362880
10! = 3628800
11! = 39916800
12! = 479001600
13! = 6227020800
14! = 87178291200
15! = 1307674368000
16! = 20922789888000
17! = 355687428096000
18! = 6402373705728000
19! = 121645100408832000
20! = 2432902008176640000