Question on Binary coversion

@zk6290254938
Task
Given a base- integer, , convert it to binary (base-). Then find and print the base- integer denoting the maximum number of consecutive 's in 's binary representation. When working with different bases, it is common to show the base as a subscript.

ex:
The binary representation of 5 is 101 , so the maximum number of consecutive 1’s is1 .

3 Likes

@007swarajbari

import math
import random
import re

n = int(input())

rmd = []

while n > 0:
rm = n % 2
n = n//2
rmd.append(rm)

count,result = 0,0

for i in range(0,len(rmd)):
if rmd[i] == 0:
count = 0
else:
count +=1
result = max(result,count)

print(result)