Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
23
Task/Sudan-function/Lua/sudan-function.lua
Normal file
23
Task/Sudan-function/Lua/sudan-function.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
function F (n, x, y)
|
||||
if n == 0 then
|
||||
return x + y
|
||||
elseif y == 0 then
|
||||
return x
|
||||
else
|
||||
return F(n - 1, F(n, x, y - 1), F(n, x, y - 1) + y)
|
||||
end
|
||||
end
|
||||
|
||||
local testCases = {
|
||||
{0, 0, 0},
|
||||
{1, 1, 1},
|
||||
{1, 3, 3},
|
||||
{2, 1, 1},
|
||||
{2, 2, 1},
|
||||
{3, 1, 1}
|
||||
}
|
||||
|
||||
for _, v in pairs(testCases) do
|
||||
io.write("F(" .. table.concat(v, ",") .. ") = ")
|
||||
print(F(unpack(v)))
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue