Where's the problem? The first line of output is immediate: 1/3=0.33333..., removing the fractional part it's 0.
For the second line keep in mind that the for
cycle is translated to something like this:
i=1;
while(i>0)
{
calls++;
i/=3;
}
So, at start i
is 1; the first iteration of the while
is executed because i
, being 1, is greater than 0. calls
is 0 and is incremented by 1, thus gets to 1. i
is divided by 3, so it gets to 0 (because the fractional part is not computed in integer division). The while
condition check is performed again, but now i
is 0, thus the cycle is not repeated. calls
remains to 1 and this value is printed on the screen.