You are viewing a single comment's thread. Return to all comments →
Scanner in = new Scanner(System.in); int n = in.nextInt() , divisor = n , count = 0 , max = 0 , power = -1; while(true) { if(divisor % 2 == 0) { if(count > max) max = count; if(divisor == 0) break; power = -1; count = 0; } else{ count ++; } divisor = divisor / 2; } System.out.println(max);
Seems like cookies are disabled on this browser, please enable them to open this website
Consecutive 1's in Binary Numbers
You are viewing a single comment's thread. Return to all comments →