<p>i think i am good at recursion loops but for some reason, my book and i are not getting the same answers....see for yourself</p>
<p>public int mystery(int k){
if (k==0) return 0;
else return (1+mystery(k/2)
}</p>
<p>i think i am good at recursion loops but for some reason, my book and i are not getting the same answers....see for yourself</p>
<p>public int mystery(int k){
if (k==0) return 0;
else return (1+mystery(k/2)
}</p>
<p>What's the question?</p>
<p>sorry guys...
its what is mystery(10)</p>
<p>bump...please help guys</p>
<p>i got 3, what'd you get</p>
<p>i got 3 too, but the answer the book says its 4....
-_-</p>
<p>anyone else want to give it a try?
and if you do get four, tell me how...</p>
<p>It's four.</p>
<p>mys(10) --> 1 + mys(5)
mys(5) ---> 1 + mys(2)
mys(2) ---> 1+ mys(1)
mys(1) ----> 1 + mys(0)
mys(0) = 0</p>
<p>Working our way up: 0 + 1 + 1 + 1 + 1 = 4</p>
<p>yep, i got 4 too</p>
<p>oh yeah, piccolojunior's right, it is 4. I skipped a step</p>
<p>thanks guys...</p>
<p>Its 4 (10 char).</p>