• + 0 comments

    i dont know how i got this: python

    if __name__ == '__main__':
        n = int(input().strip())
        if n == 0:
            print("0")
        else:
            a=[]
            while n>0:
                b=n % 2
                a.append(b)
                n= n//2
            a.reverse()
            cout=1
            c=[]
            for i in range(1, len(a)):
                if a[i]==a[i-1] and a[i]==1:
                    cout+=1
                    if i == len(a)-1:
                        c.append(cout)
                else:
                    if a[i]== 1 or a[i-1]:
                        c.append(cout)
                        cout=1
            print(max(c))