fork download
  1. USING: formatting kernel math sequences ;
  2. IN: factorial-example
  3.  
  4. : factorial ( n -- n! )
  5. iota 1 [ 1 + * ] reduce ;
  6.  
  7. 17 iota
  8. [ dup factorial "%d! = %d\n" printf ] each
Success #stdin #stdout 1.33s 164864KB
stdin
Standard input is empty
stdout
0! = 1
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