You are viewing a single comment's thread. Return to all comments →
Actually we could do the things a bit more simple here.
Here we totally avoid branching and an extra variable:
while (n > 0) { counter = ++counter * (n%2); max = Math.max(counter, max); n/=2; }
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 →
Actually we could do the things a bit more simple here.
Here we totally avoid branching and an extra variable: