3 ms·
In K (kona): f:{*/1+!x} Which could be paraphrased as "product fold 1 plus [array of numbers 0 .. x-1]", or "(reduce #'* (1+ (upto x))".
by silentbicycle 16y ago
In K (kona):
f:{*/1+!x}
Which could be paraphrased as "product fold 1 plus [array of numbers 0 .. x-1]", or "(reduce #'* (1+ (upto x))".
- sofuture 16y agoI raise you a J: f=:! f=:*/1+i. NB. included implementation because it's not a built in, but is still funny
- silentbicycle 16y agoWell, sure, but it's a predefined factorial operator. I'm sure the J version from first principles would be similar though.
- jacquesm 16y agobuilt-ins are not the same as implementations.