Recursion Output Practice - Part 2 (logN with base 2)

PHOTO EMBED

Sun Feb 06 2022 20:28:19 GMT+0000 (Coordinated Universal Time)

Saved by @Uttam #java #gfg #geeksforgeeks #lecture #recursion #intro #basecase #recursivefunction #logn

class GFG {

	
	static int fun(int n)
	{
		if(n == 1)
			return 0;
		else
			return 1 + fun(n / 2);
	}
    public static void main(String [] args) 
    {
        System.out.println(fun(16));
    }

}
content_copyCOPY

OUTPUT : ----------- 4