Given two large numbers as strings, find if one is the power of another. For Example :
Input : a = "374747", b = "52627712618930723" Output : YES Explanation : 374747^3 = 52627712618930723 Input : a = "2", b = "4099" Output : NO
Prerequisite : Multiply two large numbers represented as string
The approach is simple. First, find smaller of the two strings and then multiply it with itself until it becomes equal to or greater than the larger string. If they are equal, return true, else return false.
Below is the implementation of above approach
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.
- Modulo power for large numbers represented as strings
- Find two numbers whose difference of fourth power is equal to N
- Find ways an Integer can be expressed as sum of n-th power of unique natural numbers
- Find the numbers of strings that can be formed after processing Q queries
- Find the sum of power of bit count raised to the power B
- Find power of power under mod of a prime
- Minimum number of sub-strings of a string such that all are power of 5
- Sum of fourth power of first n even natural numbers
- Writing power function for large numbers
- Elements of Array which can be expressed as power of prime numbers
- Find value of y mod (2 raised to power x)
- Find sub-string with given power
- Program to find whether a no is power of two
- Find whether a given number is a power of 4 or not
- Find whether a given integer is a power of 3 or not
- Find the super power of a given Number
- Find multiple of x closest to or a ^ b (a raised to power b)
- Find unit digit of x raised to power y
- Find maximum power of a number that divides a factorial
- Find last five digits of a given five digit number raised to power five
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.