Given a number N. Calculate the product of all factors of N. Since Answer can be very large,compute the answer modulo 10^{9}+7.
Example 1:
Input:
N=6
Output:
36
Explanation:
Factors of 6 are 1,2,3,6.Their product is
(1*2*3*6)%(10^{9}+7)=36.
Example 2:
Input:
N=25
Output:
125
Explanation:
The factors of 25 are 1,5 and 25.
So, Their product is (1*5*25)%(10^{9}+7)
=125.
Your Task:
You don't need to read input or print anything.Your task is to complete the function factorProduct() which takes a number N as input parameter and returns the product of all factors of N.
Expected Time Complexity:O(Sqrt(N))
Expected Auxillary Space:O(1)
Constraints:
1<=N<=10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
    def factorProduct(self,N):
        #code here

Solutions:
import math

class Solution:

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


import math

class Solution:

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


class Solution:

	def factorProduct(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 % m * i
				else:
					p = p % m * i * (N // i)
		return p % m


import math

class Solution:

	def factorProduct(self, N):
		lim = int(math.sqrt(N)) + 1
		(prod, m) = (1, int(1000000000.0) + 7)
		for i in range(1, lim):
			if N % i == 0:
				if i == N // i:
					prod = prod * i % m
				else:
					prod = prod * N % m
		return prod


import math

class Solution:

	def factorProduct(self, N):
		ans = 1
		Mod = int(1000000000.0 + 7)
		for i in range(1, int(math.sqrt(N)) + 1):
			if N % i == 0:
				ans *= i
				ans %= Mod
				if N // i != i:
					ans *= N // i
					ans %= Mod
		return ans


import math

class Solution:

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


class Solution:

	def factorProduct(self, N):
		M = 10 ** 9 + 7
		prod = 1
		i = 1
		while i * i <= N:
			if N % i == 0:
				if N // i == i:
					prod = prod * i % M
				else:
					prod = prod * i % M
					prod = prod * N // i % M
			i = i + 1
		return prod


import math

class Solution:

	def factorProduct(self, N):
		p = N
		m = int(math.pow(10, 9) + 7)
		for i in range(2, int(math.sqrt(N)) + 1):
			if N % i == 0:
				p *= i
				if N // i != i:
					p *= N // i
		return p % m


import math

class Solution:

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


class Solution:

	def factorProduct(self, n):
		if n == 0:
			return 0
		p = n
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				p *= i
				if i * i == n:
					continue
				else:
					p = p * (n // i)
		ans = p % 1000000007
		return ans
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.factorProduct(N))


import math

class Solution:

	def factorProduct(self, N):
		prod = 1
		for itr in range(2, int(math.sqrt(N)) + 1):
			if N % itr == 0:
				if N // itr == itr:
					prod *= itr
				else:
					prod *= itr * (N // itr)
		prod *= N
		return prod % 1000000007
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.factorProduct(N))


class Solution:

	def factorProduct(self, N):
		k = int(N ** 0.5)
		s = {}
		for i in range(1, k + 1):
			if N % i == 0:
				s[i] = 1
				s[N // i] = 1
		p = 1
		for i in s:
			p = p * i
		return p % 1000000007
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.factorProduct(N))


class Solution:

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


class Solution:

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


import math

class Solution:

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


class Solution:

	def factorProduct(self, N):
		m = []
		for i in range(1, int(N ** 0.5) + 1):
			if N % i == 0:
				m.append(i)
				if i != N // i:
					m.append(N // i)
		r = 1
		for i in m:
			r = r * i
		return r % (10 ** 9 + 7)


class Solution:

	def factorProduct(self, n):
		prod = 1
		for x in range(1, int(pow(n, 0.5)) + 1):
			if n % x == 0:
				if x == n / x:
					prod *= x
				else:
					prod = prod * x * int(n / x)
		return prod % 1000000007


import math

class Solution:

	def factorProduct(self, N):
		prod = 1
		mod = int(1000000000.0 + 7)
		for num in range(1, int(math.sqrt(N)) + 1):
			if N % num == 0:
				prod *= num
				prod %= mod
				if N // num != num:
					prod *= N // num
					prod %= mod
		return prod


import math

class Solution:

	def factorProduct(self, N):
		l = []
		for i in range(1, int(math.sqrt(N)) + 1):
			if N % i == 0:
				l.append(i)
				l.append(N // i)
		l = set(l)
		res = 1
		for i in l:
			res *= i
		return res % (10 ** 9 + 7)


class Solution:

	def factorProduct(self, N):
		pro = 1
		i = 1
		while i * i < N:
			if N % i == 0:
				pro = pro * N
			i += 1
		if i * i == N:
			pro = pro * i
		return pro % 1000000007


class Solution:

	def factorProduct(self, N):
		pro = 1
		i = 1
		while i * i < N:
			if N % i == 0:
				pro = pro * N
			i += 1
		if i * i == N:
			pro = pro * i
		return pro % (10 ** 9 + 7)