Given a number N, find an integer denoting the smallest number evenly divisible by each number from 1 to n.
Example 1:
Input:
N = 3
Output: 6
Explanation: 6 is the smallest number 
divisible by 1,2,3.
Example 2:
Input:
N = 6
Output: 60
Explanation: 60 is the smallest number 
divisible by 1,2,3,4,5,6.
Your Task:  
You dont need to read input or print anything. Complete the function getSmallestDivNum() which takes N as input parameter and returns the smallest number evenly divisible by each number from 1 to n.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 25

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def getSmallestDivNum(self, n): 

        # code here 

Solutions:
import math

class Solution:

	def getSmallestDivNum(self, n):
		a = 1
		for i in range(2, n + 1):
			a = a * i // math.gcd(a, i)
		return a


from math import gcd

class Solution:

	def getSmallestDivNum(self, n):
		lcm = 1
		for i in range(2, n + 1):
			lcm = lcm * i // gcd(lcm, i)
		return lcm


import math

class Solution:

	def getSmallestDivNum(self, n):
		ans = 1
		for i in range(1, n + 1):
			ans = int(ans * i // math.gcd(ans, i))
		return ans


class Solution:

	def getSmallestDivNum(self, n):

		def gcd(a, b):
			if b == 0:
				return a
			return gcd(b, a % b)
		res = 1
		for i in range(1, n + 1):
			res = res * i // gcd(res, i)
		return res


class Solution:

	def getSmallestDivNum(self, n):

		def gcd(a, b):
			if a == 0:
				return b
			return gcd(b % a, a)
		lcm = 1
		for i in range(1, n + 1):
			lcm = lcm * i // gcd(min(lcm, i), max(lcm, i))
		return lcm


class Solution:

	def getSmallestDivNum(self, n):

		def gcd(a, b):
			r = a % b
			while r != 0:
				a = b
				b = r
				r = a % b
			return b

		def lcm(a, b):
			return a * b // gcd(a, b)
		res = 0
		if n == 1:
			return 1
		for i in range(1, n + 1):
			if i == 1:
				res = lcm(i, i + 1)
			else:
				res = lcm(max(i, res), min(i, res))
		return res


def gcd(a, b):
	if a == 0:
		return b
	if b == 0:
		return a
	if a > b:
		return gcd(b, a % b)
	else:
		return gcd(b % a, a)

class Solution:

	def getSmallestDivNum(self, n):
		res = 1
		for j in range(1, n + 1):
			res = res * j / gcd(res, j)
		return int(res)


class Solution:

	def getSmallestDivNum(self, n):

		def g_cd(a, b):
			if a > b:
				rem = 1
				while rem != 0:
					rem = a % b
					if rem == 0:
						break
					a = b
					b = rem
				return b
			else:
				rem = 1
				while rem != 0:
					rem = b % a
					if rem == 0:
						break
					b = a
					a = rem
				return a
		num = 1
		for i in range(2, n + 1):
			num = num * i // g_cd(num, i)
		return num


class Solution:

	def getSmallestDivNum(self, n):

		def gcd(a, b):
			if a == 0:
				return b
			return gcd(b % a, a)
		ans = 1
		for i in range(2, n + 1):
			ans = ans * i / gcd(ans, i)
		return int(ans)


class Solution:

	def find_lcm(self, num1, num2):
		if num1 > num2:
			num = num1
			den = num2
		else:
			num = num2
			den = num1
		rem = num % den
		while rem != 0:
			num = den
			den = rem
			rem = num % den
		gcd = den
		lcm = int(int(num1 * num2) / int(gcd))
		return lcm

	def getSmallestDivNum(self, n):
		ans = 1
		for i in range(2, n + 1):
			ans = Solution.find_lcm(self, ans, i)
		return ans


import math

class Solution:

	def getSmallestDivNum(self, n):
		s = 1
		for i in range(1, n + 1):
			s = s * i // math.gcd(s, i)
		return s


class Solution:

	def getSmallestDivNum(self, n):
		x = n
		for i in range(2, n):
			a = x
			b = i
			if a > b:
				(a, b) = (b, a)
			while a > 1:
				(a, b) = (b % a, a)
			if a == 1:
				b = 1
			x = x * i // b
		return x


import math

class Solution:

	def getSmallestDivNum(self, n):
		a = [i for i in range(1, n + 1)]
		lcm = a[0]
		for i in range(1, len(a)):
			lcm = lcm * a[i] // math.gcd(lcm, a[i])
		return lcm


class Solution:

	def lcm(self, a, b):
		i = 2
		s = 1
		while i <= a and i <= b:
			if a % i == 0 and b % i == 0:
				a //= i
				b //= i
				s *= i
			else:
				i = i + 1
		return s * a * b

	def getSmallestDivNum(self, n):
		k = 1
		for i in range(2, n + 1):
			j = self.lcm(k, i)
			k = j
		return k


class Solution:

	def getSmallestDivNum(self, n):
		ans = 1

		def gcd(num1, num2):
			if num1 % num2 == 0:
				return num2
			return gcd(num2, num1 % num2)
		for i in range(2, n + 1):
			ans = ans * i / gcd(ans, i)
		return int(ans)


import math as m

class Solution:

	def getSmallestDivNum(self, n):
		res = 1
		for i in range(2, n + 1):
			res = res * i // m.gcd(res, i)
		return res


class Solution:

	def getSmallestDivNum(self, n):

		def gcd(a, b):
			if a == 0:
				return b
			return gcd(b % a, a)
		arr = []
		for i in range(1, n + 1):
			arr.append(i)

		def lcm(arr, j):
			if j == len(arr) - 1:
				return arr[j]
			a = arr[j]
			b = lcm(arr, j + 1)
			return int(a * b / gcd(a, b))
		return lcm(arr, 0)


class Solution:

	def gcd(self, a, b):
		if b == 0:
			return a
		else:
			return self.gcd(b, a % b)

	def getSmallestDivNum(self, n):
		s = 1
		for i in range(2, n + 1):
			s = s * i // self.gcd(s, i)
		return s


class Solution:

	def getSmallestDivNum(self, n):

		def gcd(a, b):
			while a != b:
				if a % b == 0 or b % a == 0:
					return min(a, b)
				elif a > b:
					a = a % b
				else:
					b = b % a
			return a

		def lcm(a, b):
			return a * b // gcd(a, b)
		res = 1
		for i in range(1, n + 1):
			res = lcm(i, res)
		return res


class Solution:

	def hcf(self, x, y):
		a = min(x, y)
		b = max(x, y)
		while a != 0:
			r = b % a
			if r == 0 and a != 0:
				return a
			b = a
			a = r

	def getSmallestDivNum(self, n):
		l = 1
		for i in range(1, n):
			l = l * (i + 1) // self.hcf(l, i + 1)
		return l


import math

class Solution:

	def getSmallestDivNum(self, n):
		gc = 1
		for i in range(2, n + 1):
			gc = gc * i // math.gcd(gc, i)
		return gc

	def gcd(self, a, b):
		if a == 0:
			return b
		else:
			return gcd(b % a, a)


class Solution:

	def GCD(self, a, b):
		if b == 0:
			return a
		return self.GCD(b, a % b)

	def getSmallestDivNum(self, n):
		ans = 1
		for i in range(1, n + 1):
			ans = ans * i // self.GCD(ans, i)
		return ans


class Solution:

	def gcd(self, a, b):
		if a == 1:
			return 1
		if a > b:
			(a, b) = (b, a)
		if b % a == 0:
			return a
		(a, b) = (b % a, a)
		return self.gcd(a, b)

	def getSmallestDivNum(self, n):
		if n <= 2:
			return n
		else:
			b = self.getSmallestDivNum(n - 1)
			return n * b // self.gcd(n, b)


import math

class Solution:

	def getSmallestDivNum(self, n):
		res = 1
		for i in range(2, n + 1):
			res = res * i // math.gcd(res, i)
		return res
if __name__ == '__main__':
	t = int(input())
	for tcs in range(t):
		n = int(input())
		ob = Solution()
		print(ob.getSmallestDivNum(n))


import fractions as fr

class Solution:

	def getSmallestDivNum(self, n):
		ans = 1
		for i in range(1, n + 1):
			ans = i * ans / fr.gcd(i, ans)
		return int(ans)
if __name__ == '__main__':
	t = int(input())
	for tcs in range(t):
		n = int(input())
		ob = Solution()
		print(ob.getSmallestDivNum(n))


class Solution:

	def getSmallestDivNum(self, n):

		def gcd(a, b):
			if a == 0:
				return b
			return gcd(b % a, a)

		def lcm(a, b):
			return a / gcd(a, b) * b
		a = 1
		for x in range(2, n + 1):
			a = lcm(a, x)
		return int(a)
if __name__ == '__main__':
	t = int(input())
	for tcs in range(t):
		n = int(input())
		ob = Solution()
		print(ob.getSmallestDivNum(n))


class Solution:

	def getSmallestDivNum(self, n):
		p = 1
		for i in range(1, n + 1):
			p = p * i
		for i in range(n, 0, -1):
			d = p // i
			f = 0
			for j in range(2, n + 1):
				if d % j != 0:
					f = 1
					break
			if f == 0:
				p = d
		return p
if __name__ == '__main__':
	t = int(input())
	for tcs in range(t):
		n = int(input())
		ob = Solution()
		print(ob.getSmallestDivNum(n))