You are given a integer N and another integer K. You have to find how many integers (n) are possible such that N is the integeral part of Kth root of the integer (n).
Example 1:
Input: N = 3, K = 2
Output: 7
Explaination: 9, 10, 11, 12, 13, 14, 15 
have 3 as integral part of there square root.
Example 2:
Input: N = 2, K = 3
Output: 19
Explaination: 8, 9, 10, 11, 12, 13, 14, 15, 
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 
26 have 2 as integral part of there cube root.
Your Task:
You do not need to read input or print anything. Your task is to complete the function integralRoot() which takes N and K as input parameters and returns the number of possible integers which have N as Kth root of the integer.
Expected Time Complexity: O(LogK)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 100
1 ≤ K ≤ 8

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def integralRoot(self, N, K):

        # code here

Solutions:
class Solution:

	def integralRoot(self, N, K):
		return pow(N + 1, K) - pow(N, K)


class Solution:

	def integralRoot(self, n, k):
		return pow(n + 1, k) - pow(n, k)


class Solution:

	def integralRoot(self, N, K):
		i = N ** K
		j = (N + 1) ** K
		return j - i


class Solution:

	def integralRoot(self, N, K):
		a = N ** K
		b = (N + 1) ** K
		return b - a


import math
from math import pow

class Solution:

	def integralRoot(self, N, K):
		num = pow(N, K)
		num1 = pow(N + 1, K)
		return int(num1 - num)


class Solution:

	def integralRoot(self, N, K):
		x = N ** K
		t = (N + 1) ** K
		return t - x
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(N, K) = [int(x) for x in input().split()]
		ob = Solution()
		print(ob.integralRoot(N, K))


class Solution:

	def integralRoot(self, n, k):
		return int((n + 1) ** k - n ** k)


class Solution:

	def integralRoot(self, N, K):
		upper = (N + 1) ** K
		lower = N ** K
		return upper - lower


import math

class Solution:

	def integralRoot(self, N, K):
		return int(math.pow(N + 1, K) - math.pow(N, K))


class Solution:

	def integralRoot(self, N, K):
		n = N
		k = K
		num = pow(n, k)
		num1 = pow(n + 1, k)
		return num1 - num


class Solution:

	def integralRoot(self, N, K):
		n = N ** K
		n1 = (N + 1) ** K
		return n1 - n


class Solution:

	def integralRoot(self, N, K):
		x = N ** K
		y = (N + 1) ** K
		return y - x