RosettaCodeData/Task/Factorial/Dylan/factorial-1.dylan

8 lines
136 B
Dylan
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
define method factorial (n)
if (n < 1)
error("invalid argument");
else
reduce1(\*, range(from: 1, to: n))
end
end method;