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 can get lonely if only zeros
surround them. Formally, we call such s "sparse". A
number is defined as sparse if its binary
representation has no two consecutive bits set.
You are given an integer and your task is to find
out if it is sparse or not.
Input
The input contains an integer
Output
'Print if the number is sparse and if the number
is not sparse.
Constraints
Example #
Explanation: The binary representation of
There are no consecutive ones present in
this. So it is a sparse number.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
