in Algorithms edited by
3,172 views
6 votes
6 votes

What is the value of $F(4)$ using the following procedure:

function F(K : integer)
integer;
begin
if (k<3) then F:=k else F:=F(k-1)*F(k-2)+F(k-3)
end;
  1. $5$
  2. $6$
  3. $7$
  4. $8$
in Algorithms edited by
3.2k views

1 Answer

11 votes
11 votes
Best answer
Here f(1)=1

        f(2)=2

f(4) = f(3)*f(2)+f(1)

f(3)=f(2)*f(1)+f(0) =2*1+0=2

f(4)=2*2+1=5
selected by
Answer:

Related questions