You have given a number n. Check if a number can be represented in the form of pow(a, b) (a^b).
Input : 4 Output : Yes 2^2 = 4 Input : 12 Output : No
We have discussed two approaches in Check if a number can be expressed as x^y (x raised to power y). In this post, a more efficient solution is discussed. The idea is based on logarithmic.
Time Complexity : O(sqrt(n))
- Check if a number can be expressed as 2^x + 2^y
- Check if a number can be expressed as power | Set 2 (Using Log)
- Check if a number can be expressed as a sum of consecutive numbers
- Check if a number can be expressed as x^y (x raised to power y)
- Check if a number can be expressed as sum two abundant numbers
- Check whether a number can be expressed as a product of single digit numbers
- Check if a prime number can be expressed as sum of two Prime 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
- Check if a number with even number of digits is palindrome or not
- Program to check whether a number is Proth number or not
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.