Binary Numbers

Task
Given a base-10 integer,n, convert it to binary (base-2). Then find and print the base-10 integer denoting the maximum number of consecutive 1’s in n’s binary representation.

Sample Input 1

5
Sample Output 1

1
Sample Input 2

13
Sample Output 2

2

Explanation

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

Sample Case 2:
The binary representation of 13 is 1101, so the maximum number of consecutive 1’s is 2.

Congratulations, you passed this test case in 0.0600/4 seconds!
Input (stdin)
5
Your Output (stdout)
1
Expected Output
1

Leave a Reply

Your email address will not be published. Required fields are marked *