Given a non-negative integer n. The problem is to find the smallest perfect power of 2 which is greater than n without using the arithmetic operators.
Input : n = 10 Output : 16 Input : n = 128 Output : 256
Perfect power of 2 greater than 128: 256
Time Complexity: O(num), where num is the number of bits in the binary representation of n.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Program to find whether a no is power of two
- Smallest power of 2 greater than or equal to n
- Compute modulus division by a power-of-2-number
- Find whether a given number is a power of 4 or not
- Smallest of three integers without comparison operators
- Add two numbers without using arithmetic operators
- Bitwise right shift operators in Java
- Russian Peasant (Multiply two numbers using bitwise operators)
- Bitwise Operators in C/C++
- Check if a number is multiple of 9 using bitwise operators
- Subtract two numbers without using arithmetic operators
- Calculate 7n/8 without using division and multiplication operators
- Highest power of 2 less than or equal to given number
- Count smaller numbers whose XOR with n produces greater value
- Count smaller values whose XOR with x is greater than x
- What are the differences between bitwise and logical AND operators in C/C++?
- Operators in C | Set 2 (Relational and Logical Operators)
- Check if two numbers are equal without using arithmetic and comparison operators
- Case conversion (Lower to Upper and Vice Versa) of a string using BitWise operators in C/C++
- Toggle case of a string using Bitwise Operators
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.
Improved By : Mithun Kumar