25 lines
625 B
Text
25 lines
625 B
Text
local fmt = require "fmt"
|
|
|
|
local function F(n, x, y)
|
|
if n == 0 then return x + y end
|
|
if y == 0 then return x end
|
|
return F(n - 1, F(n, x, y - 1), F(n, x, y - 1) + y)
|
|
end
|
|
|
|
for n = 0, 1 do
|
|
print($"Values of F({n}, x, y):")
|
|
print("y/x 0 1 2 3 4 5")
|
|
print("----------------------------")
|
|
for y = 0, 6 do
|
|
io.write($"{y} |")
|
|
for x = 0, 5 do
|
|
local sudan = F(n, x, y)
|
|
fmt.write("%4d", sudan)
|
|
end
|
|
print()
|
|
end
|
|
print()
|
|
end
|
|
print($"F(2, 1, 1) = {F(2, 1, 1)}")
|
|
print($"F(3, 1, 1) = {F(3, 1, 1)}")
|
|
print($"F(2, 2, 1) = {F(2, 2, 1)}")
|