Given three numbers a, b and k, find k-th digit in ab from right side
Input : a = 3, b = 3, k = 1 Output : 7 Explanation 3^3 = 27 for k = 1. First digit is 7 in 27 Input : a = 5, b = 2, k = 2 Output : 2 Explanation 5^2 = 25 for k = 2. First digit is 2 in 25
1) Compute a^b
2) Iteratively remove the last digit until k-th digit is not meet
How to avoid overflow?
We can find power under modulo 10sup>k to avoid overflow. After finding the power under modulo, we need to return first digit of the power.
- Find unit digit of x raised to power y
- Find last five digits of a given five digit number raised to power five
- Larger of a^b or b^a (a raised to power b or b raised to power a)
- Find value of y mod (2 raised to power x)
- Number of digits in 2 raised to power n
- Print last k digits of a^b (a raised to power b)
- Check if a number can be expressed as x^y (x raised to power y)
- Find multiple of x closest to or a ^ b (a raised to power b)
- Minimum removals in a number to be divisible by 10 power raised to K
- GCD of a number raised to some power and another number
- Count of Numbers in Range where first digit is equal to last digit of the number
- Find power of power under mod of a prime
- Compute power of power k times % m
- Check if given number is a power of d where d is a power of 2
- Largest number less than N with digit sum greater than the digit sum of N
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 : vt_m