Question: Lonely Ones Binary ones ( 1 ) can get lonely if only zeros ( 0 ) surround them. Formally, we call such 1 ' s

Lonely Ones
Binary ones (1) can get lonely if only zeros (0)
surround them. Formally, we call such 1's "sparse". A
number is defined as sparse if its binary
representation has no two consecutive bits set.
You are given an integer N and your task is to find
out if it is sparse or not.
Input
The input contains an integer N.
Output
'Print '1' if the number is sparse and '0' if the number
is not sparse.
Constraints
1N1018
Example #1
Explanation: The binary representation of 3615
100100. There are no consecutive ones present in
this. So it is a sparse number.
 Lonely Ones Binary ones (1) can get lonely if only zeros

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!