Given a number N, find the product of all the divisors of N (including N).
 
Example 1:
Input : 
N = 6
Output:
36
Explanation:
Divisors of 6 : 1, 2, 3, 6
Product = 1*2*3*6 = 36 
Example 2:
Input : 
N = 5
Output:
5
Explanation:
Divisors of 5 : 1, 5
Product = 1*5 = 5 
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function divisorProduct() which takes integer N as input parameter and returns the product. Since the products may be very large, compute the answer modulo (10^{9}+ 7).
 
Expected Time Complexity: O(sqrt(N))
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= N <= 10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def divisorProduct(self, N):

        # code here 

Solutions:
class Solution:

	def divisorProduct(self, N):
		mod = 10 ** 9 + 7
		ans = 1
		for i in range(1, int(math.sqrt(N)) + 1):
			if N % i == 0:
				if N // i == i:
					ans = ans * i % mod
				else:
					ans = ans * i % mod
					ans = ans * N // i % mod
		return ans


class Solution:

	def divisorProduct(self, N):
		product = 1
		for i in range(1, int(N ** 0.5) + 1):
			if N % i == 0:
				product = product * i % (10 ** 9 + 7)
				if i != N // i:
					product = product * (N // i) % (10 ** 9 + 7)
		return product


class Solution:

	def divisorProduct(self, N):
		p = 1
		m = 10 ** 9 + 7
		for i in range(1, int(N ** 0.5) + 1):
			if N % i == 0:
				if N // i == i:
					p = p * i % m
				else:
					p = p * i % m
					p = p * N // i % m
		return p


class Solution:

	def divisorProduct(self, N):
		p = 1
		for i in range(1, int(N ** 0.5) + 1):
			if N % i == 0:
				p *= i
				if i != N // i:
					p *= N // i
		return p % 1000000007


from math import sqrt

class Solution:

	def divisorProduct(self, N):
		prod = 1
		mod = 10 ** 9 + 7
		for i in range(1, int(sqrt(N)) + 1):
			if N % i == 0:
				if N // i == 0:
					prod = prod * i
				else:
					prod = prod * i % mod
					prod = prod * N // i % mod
		return prod


class Solution:

	def divisorProduct(self, N):
		import math
		n = int(math.sqrt(N))
		count = 0
		for i in range(1, n + 1):
			if N % i == 0:
				count += 1
		return pow(N, count) % 1000000007


class Solution:

	def divisorProduct(self, N):
		p = 1
		for i in range(1, int(N ** 0.5) + 1):
			if N % i == 0:
				p = p * i
				if N // i != i:
					p = p * N // i
		return p % (10 ** 9 + 7)
import math
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.divisorProduct(N))


class Solution:

	def divisorProduct(self, N):
		mod = 10 ** 9 + 7
		ans = 1
		for i in range(1, int(math.sqrt(N)) + 1):
			if N % i == 0:
				if N // i == i:
					ans = ans * i % mod
				else:
					ans = ans * i % mod
					ans = ans * N // i % mod
		return ans
import math
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.divisorProduct(N))


import math

class Solution:

	def divisorProduct(self, N):
		m = 1
		n = 10 ** 9 + 7
		for i in range(1, int(math.sqrt(N)) + 1):
			if N % i == 0:
				m = m * i % n
				if N // i != i:
					m = m * (N // i) % n
		return m
import math
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.divisorProduct(N))


class Solution:

	def divisorProduct(self, N):
		ans = 1
		for i in range(1, int(math.sqrt(N)) + 1):
			if N % i == 0:
				if N // i == i:
					ans *= i
					ans %= 1000000007
				else:
					ans *= i
					ans %= 1000000007
					ans *= N // i
					ans %= 1000000007
		return ans