mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-15 08:24:52 +09:00
.
This commit is contained in:
1 parent
5737f4555a
commit
600392d605
1 file changed
+21
-21
@@ -42,6 +42,27 @@ local calc_number_base = {
|
||||
o = {value = 8, digits = "[0-7]"},
|
||||
}
|
||||
|
||||
local function factorial(n)
|
||||
if n < 0 then
|
||||
return error({"", {"exp-gui_calculator.error"}, {"exp-gui_calculator.factorial_neg", n}}, 0)
|
||||
|
||||
elseif n > 170 then
|
||||
return error({"", {"exp-gui_calculator.error"}, {"exp-gui_calculator.factorial_large", n}}, 0)
|
||||
end
|
||||
|
||||
if n ~= math.floor(n) then
|
||||
return error({"", {"exp-gui_calculator.error"}, {"exp-gui_calculator.factorial_int", n}}, 0)
|
||||
end
|
||||
|
||||
local result = 1
|
||||
|
||||
for i = 2, n do
|
||||
result = result * i
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
--- Function label
|
||||
Elements.calculator_function_label = Gui.define("calculator/function_label")
|
||||
:draw{
|
||||
@@ -113,27 +134,6 @@ function Elements.parse(expression)
|
||||
end
|
||||
end
|
||||
|
||||
local function factorial(n)
|
||||
if n < 0 then
|
||||
return error({"", {"exp-gui_calculator.error"}, {"exp-gui_calculator.factorial_neg", n}}, 0)
|
||||
|
||||
elseif n > 170 then
|
||||
return error({"", {"exp-gui_calculator.error"}, {"exp-gui_calculator.factorial_large", n}}, 0)
|
||||
end
|
||||
|
||||
if n ~= math.floor(n) then
|
||||
return error({"", {"exp-gui_calculator.error"}, {"exp-gui_calculator.factorial_int", n}}, 0)
|
||||
end
|
||||
|
||||
local result = 1
|
||||
|
||||
for i = 2, n do
|
||||
result = result * i
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
local parse_expr
|
||||
|
||||
local function parse_atom()
|
||||
|
||||
Reference in new issue
Block a user