You are viewing a single comment's thread. Return to all comments →
n = int(input())
binary_representation = bin(n)[2:]
consecutive_ones = binary_representation.split('0')
max_consecutive_ones = max(len(group) for group in consecutive_ones)
print(max_consecutive_ones)
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 →
Pyhton
n = int(input())
binary_representation = bin(n)[2:]
consecutive_ones = binary_representation.split('0')
max_consecutive_ones = max(len(group) for group in consecutive_ones)
print(max_consecutive_ones)