Programiz PRO
Online Java Compiler
[Link] Output
1 class HelloWorld {
2 public static void main(String[]
args) {
3 int n=14;
4
5 [Link](fun(n,0));
6 }
7 static int fun(int n, int count){
8 if(n==0){
9 return count;
10 }
11 if(n%2==0){
12 return fun(n/2,count++);
13 }
14 else{
15 return fun(n-1,count++);
16 }
17 }
18
Run