RosettaCodeData/Task/Factorial/AppleScript/factorial-1.applescript

9 lines
160 B
AppleScript
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
on factorial(x)
2016-12-05 22:15:40 +01:00
if x < 0 then return 0
set R to 1
repeat while x > 1
set {R, x} to {R * x, x - 1}
end repeat
return R
2013-04-10 21:29:02 -07:00
end factorial