Bitwise AND of Numbers Range
Welcome to the Bitwise AND Range Challenge! In this fun and educational challenge, you'll need to work with the binary versions of numbers and perform a bitwise AND operation on them. Let's see if you can find the common bits in a range of numbers!
The task is to implement a function range_bitwise_and that receives two integers, left and right, and returns the bitwise AND of all the numbers from left to right inclusive.
What is Bitwise AND?
The Bitwise AND operation compares each binary digit of two numbers. If both compared digits are 1, it produces 1; otherwise, it produces 0.
For example :
5in binary is1016in binary is1105 & 6in binary is100(which is4in decimal)
Explanation:
You have to consider the range inclusive and compute the bitwise AND for all numbers from left to right.
Example:
range_bitwise_and(5, 7) # returns 4 a# Explanation: Bitwise AND for numbers 5 (101), 6 (110), and 7 (111) results in 4 (100) range_bitwise_and(0, 1) # returns 0
Are you ready to take on the challenge? Let's go!
Note: The numbers involved in the function are non-negative integers.
Inputs
Arg 1:
5Arg 2:
7Expected Output
4Actual Output