function G(n: integer): integer; forward;
function F(n: integer): integer;
begin
if n = 1 then result := 1
else result := F(n - 1) - G(n - 1)
end;
function G(n: integer): integer;
else result := F(n - 1) + 2 * G(n - 1)
Println(F(5)/G(5));//-2
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
function G(n: integer): integer; forward;
function F(n: integer): integer;
begin
if n = 1 then result := 1
else result := F(n - 1) - G(n - 1)
end;
function G(n: integer): integer;
begin
if n = 1 then result := 1
else result := F(n - 1) + 2 * G(n - 1)
end;
begin
Println(F(5)/G(5));//-2
end.
G(1) = 1;
F(2) = F(1) - G(1) = 0;
G(2) = F(1) +2*G(1) = 1 + 2*1 = 3;
F(3) = F(2) - G(2) = 0 - 3 = -3;
G(3) = F(2) + 2*G(2) = 0 + 2*3 = 6;
F(4) = F(3) - G(3) -3 - 6 = -9;
G(4) = F(3) + 2*G(3) = -3 + 2*6 = 9;
F(5) = F(4) - G(4)= -9 - 9 = -18;
G(5) = F(4) + 2*G(4) = -9 + 2*9 = 9;
F(1) = 1;
G(1) = 1;
F(2) = F(1) - 2*G(1) = -1;
G(2) = F(1) + G(1) = 1 + 1 = 2;
F(3) = F(2) - 2*G(2) = -1 - 2*2 = -5;
G(3) = F(2) + G(2) = -1 + 2 = 1;
F(4) = F(3) - 2*G(3) -5 - 2*(1) = -7;
G(4) = F(3) + G(3) = -5 + 1 = -4;
F(5) = F(4) - 2*G(4)= -7 - 2*(-4) = 1;
G(5) = F(4) + G(4) = -7 + -4 = -11;
Trunc(F(5)/G(5)) = 0
Остальные две пусть сам(а) пишет