Calculate factorial of a given number N.
 
Example 1:
Input: 5
Output: 120
Explanation: 1 * 2 * 3 * 4 * 5 = 120.
 
Your Task:
You don't need to read or print anything. Your task is to complete the function find_fact() which takes n as input parameter and returns factorial of N.
 
Expected Time Complexity: O(N)
Expected Space Complexity: O(1)
 
Constraints:
1 <= N <= 18

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
	def find_fact(self, n):
		# Code here

Solutions:
class Solution:

	def find_fact(self, n):
		if n == 0 or n == 1:
			return 1
		else:
			return n * self.find_fact(n - 1)


class Solution:

	def find_fact(self, n):
		c = 1
		for i in range(1, n + 1):
			c = c * i
		return c


class Solution:

	def find_fact(self, n):
		if n <= 1:
			return 1
		else:
			return n * self.find_fact(n - 1)


class Solution:

	def find_fact(self, n):
		fact = 1
		if n == 1:
			return fact
		else:
			for i in range(1, n + 1):
				fact = fact * i
		return fact


import math

class Solution:

	def find_fact(self, n):
		a = math.factorial(n)
		return a


class Solution:

	def find_fact(self, n):
		fact = 1
		for i in range(2, n + 1):
			fact *= i
		return fact


class Solution:

	def find_fact(self, n):
		(i, result) = (1, 1)
		while i <= n:
			result *= i
			i += 1
		return result


import functools

class Solution:

	def find_fact(self, n):
		if n >= 1 and n <= 18:
			return functools.reduce(lambda a, b: a * b, [a for a in range(1, n + 1)])
		else:
			return 0


class Solution:

	def find_fact(self, n):
		if n == 0:
			return 1
		return self.find_fact(n - 1) * n


class Solution:

	def find_fact(self, n):
		product = 1
		while n >= 1:
			product *= n
			n -= 1
		return product


class Solution:

	def find_fact(self, n):

		def fact(x):
			if x == 0:
				return 1
			return x * fact(x - 1)
		return fact(n)


from math import factorial

class Solution:

	def find_fact(self, n):
		return factorial(n)


class Solution:

	def find_fact(self, n):
		k = 1
		while n != 0:
			k = k * n
			n = n - 1
		return k


import math

class Solution:

	def find_fact(self, n):
		d = math.factorial(n)
		return d


class Solution:

	def find_fact(self, n):
		fact = 1
		i = n
		while i >= 1:
			fact = fact * i
			i = i - 1
		return fact


class Solution:

	def find_fact(self, n):
		prod = 1
		while n > 0:
			prod *= n
			n -= 1
		return prod


class Solution:

	def find_fact(self, n):
		i = 0
		ans = 1
		while i < n:
			ans = ans * (n - i)
			i += 1
		return ans


class Solution:

	def find_fact(self, n):
		fact = 1
		while n > 0:
			fact = fact * n
			n = n - 1
		return fact