Ask your own question, for FREE!
Mathematics 18 Online
OpenStudy (anonymous):

int f(int n){static int r=0;if(n<=0) return1;if(n>3) (r=n;return f(n-2)+2;}returnf(n-1)+r;} what will be the value of f(5)

OpenStudy (dumbcow):

this is a recursive algorithm f(5) = f(3) +2 f(3) = f(2) + 5 f(2) = f(1) +5 f(1) = f(0) + 5 f(0) = 1 --> f(5) = 1 +5+5+5+2 = 18

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!