The binary representation of given numbers
You can do this in two way that is Iterative and Recursive method. Let’s have a look number 5 is represented in binary as (0100)with the base 2. As we all know binary values can be represented as 0 or 1.
Iterative method:
Algorithm:
1. Firstly the given number or desired number ‘value’ and we want to check whether it’s 0th bit is 1 or 0
bit = 2 ^ 0 (0th bit)
if value & bit == 1 means 0th bit is 1 else 0th bit is 0