Given a binary string str, the task is to find the largest power of 2 that divides the decimal equivalent of the given binary number.
Input: str = “100100”
22 = 4 is the highest power of 2 that divides 36 (100100).
Input: str = “10010”
Approach: Starting from the right, count the number of 0s in the binary representation which is the highest power of 2 which will divide the number.
Below is the implementation of the above approach:
- Highest power of two that divides a given number
- Highest power of a number that divides other number
- Highest power of 2 less than or equal to given number
- Find maximum power of a number that divides a factorial
- Check in binary array the number represented by a subarray is odd or even
- Modulo power for large numbers represented as strings
- Find two co-prime integers such that the first divides A and the second divides B
- Check if given number is a power of d where d is a power of 2
- Find the missing element in an array of integers represented in binary format
- Minimum value that divides one number and divisible by other
- Largest number that divides x and is co-prime with y
- Check if the sum of digits of a number N divides it
- Check if a given number divides the sum of the factorials of its digits
- Greatest divisor which divides all natural number in range [L, R]
- Find a number that divides maximum array elements
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.