Interest in Pascal (1)

Look at this Pascal ( pseudocode ) below :

 function secret(x, y : longint) : longint;
 begin
      if (y = 0) then
           secret := 1
      else
           secret := x * secret(x,y-1)
 end;

What is the value of s e c r e t ( 8 , 5 ) secret(8,5) ?


The answer is 32768.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

secret(8,5)=8 secret(8,4)=8 8 secret(8,3)=8 8 8 secret(8,2)=8 8 8 8 secret(8,1)=8 8 8 8 8 secret(8,1)=8 8 8 8 8 8 secret(8,0)=8 8 8 8 8 8*1=32768

NB: secret(8,0)=1 because y=0

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...