2020-12-05 23:58:56 +00:00
|
|
|
proto test
|
2023-02-09 21:58:25 +00:00
|
|
|
func __init(self, x)
|
2021-01-12 23:49:16 +00:00
|
|
|
self:setArg(x)
|
2020-11-13 05:04:09 +00:00
|
|
|
end
|
2020-11-06 01:53:55 +00:00
|
|
|
|
2023-02-09 21:58:25 +00:00
|
|
|
func __tostring(self)
|
|
|
|
let total = 1
|
2020-11-13 23:39:47 +00:00
|
|
|
|
2023-02-09 21:58:25 +00:00
|
|
|
for (let i = self.x; i > 0; i = i - 1) do
|
2020-11-13 23:39:47 +00:00
|
|
|
total = total * i;
|
|
|
|
end
|
2020-11-13 05:04:09 +00:00
|
|
|
|
2021-01-03 23:35:52 +00:00
|
|
|
return "The factorial of " .. self.x .. " is " .. total
|
2020-11-13 23:39:47 +00:00
|
|
|
end
|
|
|
|
|
2023-02-09 21:58:25 +00:00
|
|
|
func setArg(self, x)
|
2020-11-13 23:39:47 +00:00
|
|
|
self.x = x
|
2020-11-13 05:04:09 +00:00
|
|
|
end
|
2020-11-06 01:53:55 +00:00
|
|
|
end
|
|
|
|
|
2023-02-09 21:58:25 +00:00
|
|
|
let t = test(1)
|
2020-11-13 23:39:47 +00:00
|
|
|
|
2023-02-09 21:58:25 +00:00
|
|
|
for (let x = 1; x < 1000; x = x + 1) do
|
|
|
|
for (let i = 1; i < 100; i = i + 1) do
|
2021-01-12 23:49:16 +00:00
|
|
|
t:setArg(i)
|
2020-11-13 05:04:09 +00:00
|
|
|
|
2021-01-03 23:35:52 +00:00
|
|
|
print(t)
|
2020-11-13 23:39:47 +00:00
|
|
|
end
|
|
|
|
end
|