You are viewing a single comment's thread. Return to all comments →
Your code inspired me for the following solution in Groovy:
int n = (new Scanner(System.in)).nextInt() int max,overAllMax = 0 while(n>0){ if(n%2==1){ max++ overAllMax = Integer.max(overAllMax, max) } else { overAllMax = Integer.max(overAllMax, max) max=0 } n=n/2 } print overAllMax
Seems like cookies are disabled on this browser, please enable them to open this website
Day 10: Binary Numbers
You are viewing a single comment's thread. Return to all comments →
Your code inspired me for the following solution in Groovy: