The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+4 votes
1.4k views

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 by Veteran (98.3k points) | 1.4k views

1 Answer

+9 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
by Veteran (113k points)
selected by
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,807 questions
54,711 answers
189,258 comments
79,676 users