RosettaCodeData/Task/Factorial/YAMLScript/factorial.ys

11 lines
136 B
Text
Raw Permalink Normal View History

2025-02-27 18:35:13 -05:00
!YS-v0
2023-12-16 21:33:55 -08:00
2025-08-12 11:43:10 -07:00
defn main(*ns):
each n ns:
say: "$n! -> $factorial(n)"
2023-07-09 17:42:30 -04:00
2024-03-06 22:25:12 -08:00
defn factorial(x):
2025-08-12 11:43:10 -07:00
if x <= 2:
(x ||| 1)
(2 .. x).mul(*)