a 0 b 27 c 29 d 36 e nothing the method runs foreverSolution

a) 0

b) 27

c) 29

d) 36

e) nothing, the method runs forever

Solution

for example(3) it runs as n!=0 so it runs example(2) + 3*3*3 = example2)+27

now example (2) is calculated.

it retuns example(1)+2*2*2= example(1)+8

now example(1) returns

example(0)+1*1*1= example(0)+1

example(0) returns 0

so example(1) becomes equal to 1

which is returned to example (2) now exsmple 2 becomes 1+8=9

this is returned to example(3) which gives 9+27 =36

Ans is D) 36.

a) 0 b) 27 c) 29 d) 36 e) nothing, the method runs foreverSolutionfor example(3) it runs as n!=0 so it runs example(2) + 3*3*3 = example2)+27 now example (2) is

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site