Convert decimal to binary number, then count the consecutive 1's in the binary number.

Convert decimal to binary number, then count the consecutive 1's in the binary number.

Input: 63

Output: 6
Explanation: 63 decimal format
binary format for 63 is 111111, so there are 6 consecutive 1's in the binary number.

another example: If input is 13, binary format is 1101, so the output is 2.

another example : input 439
output is 3.
Since binary format is 110110111. 3 consecutive 1's are found to be highest in it.
next example: input 65535
output is 16.
since binary format is 1111111111111111. 16 consecutive 1's are found to be highest in it.

Comments

Popular posts from this blog

Reasoning-Number Series

Reasoning-Letter Series

Multiply Negative numbers in java