Given a number n, we need to check if it can be expressed as 2x + 2y or not . Here x and y can be equal.
Input : 24 Output : Yes Explanation: 24 can be expressed as 24 + 23 Input : 13 output : No Explanation: It is not possible to express 13 as sum of two powers of 2.
If we take few examples, we can notice that a number can be expressed in the form of 2^x + 2^y if the number is already a power of 2 ( for n > 1 ) or the remainder we get after subtracting previous power of two from the number is also a power of 2.
Below is the implementation of above idea
16 4 No
- Check if a number can be expressed as a^b | Set 2
- Check if a number can be expressed as power | Set 2 (Using Log)
- Check if a number can be expressed as x^y (x raised to power y)
- Check if a number can be expressed as a sum of consecutive numbers
- Check whether a number can be expressed as a product of single digit numbers
- Check if an integer can be expressed as a sum of two semi-primes
- Number expressed as sum of five consecutive integers
- N expressed as sum of 4 prime numbers
- Find ways an Integer can be expressed as sum of n-th power of unique natural numbers
- Check if a number is divisible by all prime divisors of another number
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Program to check whether the given number is Buzz Number or not
- Check if a number with even number of digits is palindrome or not
- Program to check whether a number is Proth number or not
- Check if a number has same number of set and unset bits
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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 : Chandan_Kumar