Soal dan Pembahasan OSK Komputer 2014

  1. Perhatikan fungsi di bawah ini.

    function wow(x:integer):integer;
    begin
    	if (x < 2) then wow := x
    	else wow := wow(x-2) + 3*wow(x-1);
    end;
    

    Apa yang akan dikembalikan pada pemanggilan fungsi wow(8) ?

      1. 3620
      2. 3760
      3. 3824
      4. 3927
      5. 4126

    wow(0) = 0
    wow(1) = 1
    wow(2) = wow(0) + 3*wow(1) = 3
    wow(3) = wow(1) + 3*wow(2) = 10
    wow(4) = wow(2) + 3*wow(3) = 33
    wow(5) = wow(3) + 3*wow(4) = 109
    wow(6) = wow(4) + 3*wow(5) = 360
    wow(7) = wow(5) + 3*wow(6) = 1189
    wow(8) = wow(6) + 3*wow(7) = 3927 (D).

Share Now:

5 1 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x

Follow TikTok Kami @cahinfor

Pembahasan soal tahun 2023 sudah tersedia di TikTok Kami loh!