GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
583 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
asked in Algorithms by Veteran (77.8k points)   | 583 views

1 Answer

+5 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
answered by Veteran (54.9k points)  
selected by


Top Users Jun 2017
  1. Bikram

    3704 Points

  2. Hemant Parihar

    1502 Points

  3. junaid ahmad

    1432 Points

  4. Arnab Bhadra

    1416 Points

  5. Niraj Singh 2

    1391 Points

  6. Debashish Deka

    1246 Points

  7. Rupendra Choudhary

    1194 Points

  8. rahul sharma 5

    1158 Points

  9. Arjun

    956 Points

  10. srestha

    950 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 Jun 19 - 25
  1. Bikram

    1960 Points

  2. Niraj Singh 2

    1386 Points

  3. junaid ahmad

    502 Points

  4. Debashish Deka

    414 Points

  5. sudsho

    410 Points


23,373 questions
30,079 answers
67,406 comments
28,396 users