Given the A and R i,e first term and common ratio of a GP series. Find the Nth term of the series.
Note: As the answer can be rather large print its modulo 1000000007 (10^{9} + 7).
Example 1:
Input: A = 2, R = 2, N = 4
Output: 16
Explanation: The GP series is 
2, 4, 8, 16, 32,... in which 16 
is th 4th term.
Example 2:
Input: A = 4, R = 3, N = 3
Output: 36
Explanation: The GP series is
4, 12, 36, 108,.. in which 36 is
the 3rd term.
 
Your Task:
You don't need to read or print anything. Your task is to complete the function Nth_term() which takes A, R and N as input parameter ans returns Nth term of the GP series modulo 10^{9} + 7.
 
Expected Time Complexity: O(log_{2}(N))
Expected Space Complexity: O(1)
Constraints:
1 <= A, R, N <= 1000000

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(log_{2}(N))
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
	def Nth_term(self, a, r, n):
		# Code here

Solutions:
class Solution:

	def Nth_term(self, a, r, n):
		mod = pow(10, 9) + 7
		n = a * pow(r, n - 1, mod) % mod
		return n


import math as m

class Solution:

	def Nth_term(self, a, r, n):
		mod = pow(10, 9) + 7
		n = a * pow(r, n - 1, mod) % mod
		return n


class Solution:

	def Nth_term(self, a, r, n):
		m = 10 ** 9 + 7
		term = a * pow(r, n - 1, m)
		return term % m


def pwer(r, l, m):
	if l == 0:
		return 1
	elif l == 1:
		return r
	else:
		y = pwer(r, l // 2, m)
		if l % 2 == 0:
			return y * y % m
		else:
			return r * y * y % m

class Solution:

	def Nth_term(self, a, r, n):
		m = 10 ** 9 + 7
		term = a * pwer(r, n - 1, m)
		return term % m


import math

class Solution:

	def Nth_term(self, a, r, n):
		mod = 1000000007
		return math.floor(a * pow(r, n - 1, mod)) % mod


class Solution:

	def Nth_term(self, a, r, n):
		MOD = 1000000007
		return a * pow(r, n - 1, MOD) % MOD


class Solution:

	def Nth_term(self, A, R, N):
		MOD = 1000000007
		power = pow(R, N - 1, MOD)
		return A * power % MOD


class Solution:

	def Nth_term(self, a, r, n):
		mod = 1000000007
		res = a * pow(r, n - 1, mod)
		return res % mod


class Solution:

	def Nth_term(self, a, r, n):
		mod_term = int(1000000000.0) + 7
		nth_term = a * self.power(r, n - 1, mod_term)
		return nth_term % mod_term

	def power(self, base, exponent, mod_term):
		if exponent == 0:
			return 1
		if exponent % 2 == 0:
			p = self.power(base, exponent / 2, mod_term)
			return p * p % mod_term
		else:
			p = self.power(base, (exponent - 1) / 2, mod_term)
			return p * p * base % mod_term


import math

class Solution:

	def pow(self, x: int, n: int, M: int) -> int:
		result = 1
		while n > 0:
			if n % 2 == 1:
				result = result * x % M
			x = x * x % M
			n //= 2
		return result

	def Nth_term(self, a, r, n):
		m = int(1000000000.0 + 7)
		res = self.pow(r, n - 1, m)
		res *= a
		res %= m
		return int(res)


class Solution:

	def __init__(self):
		pass

	def powm(self, x: int, n: int, M: int) -> int:
		result = 1
		while n > 0:
			if n % 2 == 1:
				result = result * x % M
			x = x * x % M
			n //= 2
		return result

	def Nth_term(self, a: int, r: int, n: int) -> int:
		mod = int(1000000000.0 + 7)
		res = self.powm(r, n - 1, mod)
		res *= a
		res %= mod
		return int(res)


class Solution:

	def Nth_term(self, a, r, n):
		MOD = 10 ** 9 + 7
		rn = pow(r, n - 1, MOD)
		tn = a * rn % MOD
		return tn


class Solution:

	def Nth_term(self, a, r, n):
		mod = 10 ** 9 + 7
		ele = a * self.power(r, n - 1)
		return ele % mod

	def power(self, r, n):
		mod = 10 ** 9 + 7
		if n == 0:
			return 1
		ele = self.power(r, n // 2) % mod
		ele = ele * ele % mod
		if n % 2 == 0:
			return ele % mod
		return r * ele % mod


import math

class Solution:

	def Nth_term(self, a, r, n):
		a = a % (10 ** 9 + 7)
		r = r % (10 ** 9 + 7)
		return pow(r, n - 1, 10 ** 9 + 7) * a % (10 ** 9 + 7)


class Solution:

	def Nth_term(self, a, r, n):
		c = 10 ** 9 + 7
		d = pow(r, n - 1, c)
		return a * d % c


class Solution:

	def Nth_term(self, a, r, n):

		def power(g, e):
			if e == 0:
				return 1
			t = power(g, e // 2) % 1000000007
			t = t * t % 1000000007
			if e % 2 == 0:
				return t % 1000000007
			return g * t % 1000000007
		return a * power(r, n - 1) % 1000000007


def power(a, b):
	mod = int(1000000000.0 + 7)
	res = 1
	while b:
		if b % 2 == 1:
			res = res * a % mod
		b = b >> 1
		a = a * a % mod
	return res % mod

class Solution:

	def Nth_term(self, a, r, n):
		mod = int(1000000000.0 + 7)
		return a * power(r, n - 1) % mod


class Solution:

	def Nth_term(self, a, r, n):
		p = 1000000007
		if n == 0:
			return 1
		return a % p * pow(r, n - 1, p) % p


class Solution:

	def Nth_term(self, a, r, n):
		x = pow(r, n - 1, 10 ** 9 + 7)
		y = a * x
		return y % (pow(10, 9) + 7) if r > 1 else a * r


class Solution:

	def Nth_term(self, a, r, n):
		m = 1000000007
		a = a % m
		rpn = pow(r, n - 1, m)
		return a * rpn % m


d = 1000000007
import math

class Solution:

	def Nth_term(self, a, r, n):
		new_n = n - 1
		cur_r_mod_d = 1
		while new_n:
			temp_r_mod_d = r % d
			power = int(math.log(new_n, 2))
			for i in range(1, power + 1):
				temp_r_mod_d = temp_r_mod_d ** 2 % d
			new_n = new_n - 2 ** power
			cur_r_mod_d = cur_r_mod_d * temp_r_mod_d % d
		return a * cur_r_mod_d % d


class Solution:

	def Nth_term(self, a, r, n):
		mod_v = 1000000007
		po = pow(r, n - 1, mod_v)
		return a % mod_v * po % mod_v


class Solution:

	def Nth_term(self, A, R, N):
		mod_val = 1000000007
		pow_val = pow(R, N - 1, mod_val)
		return A % mod_val * pow_val % mod_val


class Solution:

	def powerNum(self, r, n):
		m = 10 ** 9 + 7
		if n == 0:
			return 1
		t = self.powerNum(r, n // 2) % m
		t = t * t % m
		if n % 2 == 0:
			return t % m
		return r * t % m

	def Nth_term(self, a, r, n):
		m = 10 ** 9 + 7
		p = self.powerNum(r, n - 1)
		x = a * p % m
		return x % m


import math

class Solution:

	def Nth_term(self, a, r, n):
		return int(a * pow(r, n - 1, 1000000007) % 1000000007)


class Solution:

	def power(self, b, e, mod):
		if e == 0:
			return 1
		k = self.power(b, e // 2, mod) % mod
		k = k * k % mod
		if e % 2 == 0:
			return k
		return k * b % mod

	def Nth_term(self, a, r, n):
		mod = 1000000007
		return a * self.power(r, n - 1, mod) % mod