2022-09-18 14:50:20 +02:00
|
|
|
for := [ start stop iteration |
|
2022-05-17 16:10:56 +02:00
|
|
|
if (start > stop)
|
2022-05-22 05:29:41 +02:00
|
|
|
[nil]
|
|
|
|
[iteration start; for (start + 1) stop iteration]
|
2022-05-17 16:10:56 +02:00
|
|
|
];
|
|
|
|
|
2022-09-18 14:50:20 +02:00
|
|
|
factorial := [n | if (n <= 1) [1] [n * (factorial (n-1))]];
|
2022-05-17 16:10:56 +02:00
|
|
|
for 1 10 [i | say (factorial i)];
|
2022-06-06 04:22:59 +02:00
|
|
|
|
2022-09-18 14:50:20 +02:00
|
|
|
factorial_iterative := [n |
|
|
|
|
x := 1;
|
2022-06-06 04:22:59 +02:00
|
|
|
for 1 n [i|x *= i];
|
|
|
|
x
|
|
|
|
];
|
|
|
|
for 1 10 [i | say (factorial_iterative i)];
|