is there a mathematical formula to calculate how many times the recursive function is called for the following without having to check with my complier
How many times will mystery2 be called recursively when invoked with the call mystery2(1000)?
public void mystery2(int n)
{
if (n <= 1)
System.out.print(n);
else
{
mystery2(n / 2);
System.out.print(", " + n);
}
}
1, 3, 7, 15, 31, 62, 125, 250, 500, 1000 = 10 times