musique/examples/factorial.mq

10 lines
214 B
Plaintext
Raw Normal View History

2022-05-17 16:10:56 +02:00
var for = [ start stop iteration |
if (start > stop)
[nil]
[iteration start; for (start + 1) stop iteration]
2022-05-17 16:10:56 +02:00
];
var 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)];