Write a program to find the factorial value of any number entered by the user.

-----Input-----

The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains an integer N. 

-----Output-----
For each test case, display the factorial of the given number N in a new line.

-----Constraints-----
- 1 ≤ T ≤ 1000
- 0 ≤ N ≤ 20

-----Example-----
Input
3 
3 
4
5

Output

6
24
120

Difficulty: EASY
Tags: Mathematics

Implementation

Starter code:

Solutions:
for i in range(int(input())):
	n = int(input())
	p = 1
	for i in range(1, n + 1):
		p = p * i
	print(p)


t = int(input())
for i in range(t):
	n = int(input())
	fact = 1
	for i in range(1, n + 1):
		fact *= i
	print(fact)


for _ in range(int(input())):
	n = int(input())
	fact = 1
	if n == 1:
		print(1)
	else:
		for i in range(n, 1, -1):
			fact *= i
		print(fact)


def factorial(n):
	if n == 0:
		return 1
	else:
		return n * factorial(n - 1)
t = int(input())
for i in range(t):
	n = int(input())
	print(factorial(n))


T = int(input())
for i in range(T):
	N = int(input())
	Number = ''
	for l in range(1, N + 1):
		Number += str(l)
	Multiply = 1
	for j in range(len(Number)):
		Multiply = Multiply * int(Number[j])
	print(Multiply)


T = int(input())
for i in range(0, T):
	n = int(input())
	sum = 1
	for j in range(1, n + 1):
		sum = sum * j
	print(sum)


for i in range(int(input())):
	n = int(input())
	x = 1
	for i in range(1, n + 1):
		x = x * i
	print(x)


T = int(input())
for i in range(T):
	N = int(input())
	Number = 1
	for l in range(1, N + 1):
		Number *= l
	print(Number)


for i in range(int(input())):
	n = int(input())
	k = 1
	for j in range(1, n + 1):
		k = k * j
	print(k)


t = int(input())
fact = [1, 1]
for i in range(2, 21):
	fact.append(i * fact[i - 1])
for i in range(t):
	n = int(input())
	print(fact[n])


x = int(input())
for i in range(x):
	s = int(input())
	fact = 1
	for i in range(1, s + 1):
		fact = fact * i
	print(fact)


for i in range(int(input())):
	factorial = 1
	N = int(input())
	for j in range(N):
		factorial *= j + 1
	print(factorial)


tc = int(input())
for i in range(tc):
	x = int(input())
	f = 1
	for j in range(1, x + 1):
		f *= j
	print(f)


import math
t = int(input())
i = 0
while i < t:
	n = int(input())
	print(math.factorial(n))
	i += 1


def fact(a):
	if a == 1 or a == 0:
		return 1
	else:
		return a * fact(a - 1)
t = int(input())
for i in range(t):
	a = int(input())
	ans = fact(a)
	print(ans)


import math
n = int(input())
print()
while n > 0:
	x = int(input())
	print(math.factorial(x))
	n = n - 1


def factorial(n):
	fact = 1
	for i in range(1, n + 1):
		fact = fact * i
	return fact
t = int(input())
for i in range(t):
	n = int(input())
	print(factorial(n))


for i in range(int(input())):
	n = int(input())
	s = 1
	for i in range(1, n + 1):
		s = s * i
	print(s)


import math
for j in range(int(input())):
	x = int(input())
	print(math.factorial(x))


t = int(input())
for i in range(t):
	N = int(input())
	f = 1
	for i in range(1, N + 1):
		f = f * i
	print(f)


t = int(input())
for i in range(t):
	n = int(input())
	m = 1
	for j in range(n):
		m = m * (n - j)
	print(m)


for i in range(int(input())):
	n = int(input())
	fact = 1
	if n == 1 or n == 0:
		print('1')
	else:
		for j in range(1, n + 1):
			fact = fact * j
		print(fact)


def abc(a):
	if a == 0 or a == 1:
		return 1
	else:
		return a * abc(a - 1)
for i in range(int(input())):
	a = int(input())
	print(abc(a))


import math
t = int(input())
for i in range(t):
	p = int(input())
	print(math.factorial(p))


def fun(n):
	if n == 0 or n == 1:
		return 1
	else:
		return n * fun(n - 1)
for i in range(int(input())):
	n = int(input())
	print(fun(n))


import math
t = int(input())
for i in range(t):
	n = int(input())
	print(math.factorial(n))


t = int(input())
for i in range(t):
	n = int(input())
	f = 1
	while n > 0:
		f = f * n
		n = n - 1
	print(f)


t = int(input())

def fact(n):
	if n == 1 or n == 0:
		return 1
	else:
		return n * fact(n - 1)
while t != 0:
	n = int(input())
	print(fact(n))
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	f = 1
	if n == 0:
		print(1)
	else:
		for j in range(1, n + 1):
			f = f * j
		print(f)


def factorial(N):
	if N == 1 or N == 0:
		return 1
	else:
		return N * factorial(N - 1)
T = int(input())
for i in range(T):
	N = int(input())
	print(factorial(N))


import math
for _ in range(int(input())):
	print(math.factorial(int(input())))


T = int(input())
for i in range(T):
	N = int(input())
	x = 1
	for j in range(N):
		x = x * (N - j)
	print(x)


import math
for t in range(int(input())):
	num = int(input())
	f = 1
	for i in range(1, num + 1):
		f = f * i
	print(f)


t = int(input())
for i in range(t):
	n = int(input())
	a = 1
	for j in range(1, n + 1):
		a = a * j
	print(a)


s = int(input())
for i in range(s):
	t = int(input())
	mul = 1
	for j in range(1, t + 1):
		mul = mul * j
	print(mul)


t = int(input())
for _ in range(t):
	n = int(input())
	p = 1
	for i in range(1, n + 1):
		p = p * i
	print(p)


for i in range(int(input())):
	n = int(input())
	p2 = 1
	for i in range(1, n + 1):
		p2 = p2 * i
	print(p2)


from functools import reduce
n = int(input())
for i in range(1, n + 1):
	num = int(input())
	if num <= 1:
		print(1)
	else:
		print(reduce(lambda x, y: x * y, [j for j in range(1, num + 1)]))


import math
n = int(input())
for i in range(n):
	s = int(input())
	print(math.factorial(s))


t = int(input())
for i in range(t):
	x = int(input())
	fact = 1
	for i in range(1, x + 1):
		fact = fact * i
	print(fact)


for i in range(int(input())):
	n = int(input())
	f = 1
	for j in range(1, n + 1):
		f = f * j
	print(f)


for _ in range(int(input())):
	answer = 1
	for i in range(int(input())):
		answer *= i + 1
	print(answer)


def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)
t = int(input())
for _ in range(t):
	n = int(input())
	print(factorial(n))


global a
a = [1, 2, 6]

def fa(n):
	if n == 1 or n == 0:
		return 1
	else:
		return n * fa(n - 1)
t = int(input())
for i in range(t):
	d = int(input())
	print(fa(d))


for i in range(int(input())):
	n = int(input())
	fact = 1
	for j in range(1, n + 1):
		fact = fact * j
	print(fact)


import math
for i in range(int(input())):
	sum = math.factorial(int(input()))
	print(sum)


def fac(n):
	s = n
	if n == 1:
		return 1
	else:
		s = s * fac(n - 1)
	return s
for j in range(int(input())):
	z = int(input())
	if z == 0:
		print(1)
	else:
		print(fac(z))


import math

def facto(n):
	return math.factorial(n)
t = int(input())
while t:
	t = t - 1
	n = int(input())
	print(facto(n))


for i in range(int(input())):
	a = int(input())
	f = 1
	for i in range(1, a + 1):
		f *= i
	print(f)


num = int(input())
for i in range(num):
	ans = 1
	n1 = int(input())
	for j in range(1, n1 + 1):
		ans = ans * j
	print(ans)


u = int(input())
for j in range(u):
	N = int(input())
	f = 1
	for j in range(1, N + 1):
		f = f * j
	print(f)


for _ in range(int(input())):
	n = int(input())
	fact = 1
	while n:
		fact = fact * n
		n -= 1
	print(fact)


for i in range(int(input())):
	n = int(input())
	a = 1
	for i in range(1, n + 1):
		a = a * i
	print(a)


def fact(n):
	if n == 0 or n == 1:
		return 1
	else:
		return n * fact(n - 1)
n = int(input())
for i in range(n):
	T = int(input())
	print(fact(T))


try:
	t = int(input())
	for i in range(0, t):
		n = int(input())
		fact = 1
		while n != 0:
			fact = fact * n
			n -= 1
		print(fact)
except:
	pass


for i in range(int(input())):
	n = int(input())
	y = 1
	for i in range(1, n + 1):
		y = y * i
	print(y)


t = int(input())
for _ in range(t):
	n = int(input())
	res = 1
	for i in range(1, n + 1):
		res *= i
	print(res)


for k in range(int(input())):
	n = int(input())
	fact = 1
	for j in range(1, n + 1):
		fact = fact * j
	print(fact)


for i in range(int(input())):
	n = int(input())
	ans = 1
	for j in range(1, n + 1):
		ans *= j
	print(ans)


for _ in range(int(input())):
	x = int(input())
	a = 1
	for i in range(1, x + 1):
		a = a * i
	print(a)


x = int(input())
for i in range(x):
	a = int(input())
	f = 1
	while a > 0:
		f = f * a
		a = a - 1
	print(f)


import math
t = int(input())
for i in range(t):
	n = int(input())
	p = 1
	for i in range(1, n + 1):
		p = p * i
	print(p)


import math
for m in range(int(input())):
	print(math.factorial(int(input())))


T = int(input())
for tc in range(T):
	N = int(input())
	if N <= 1:
		print('1')
	else:
		fact = 1
		for i in range(1, N + 1):
			fact = fact * i
		print(fact)


n = int(input())
for i in range(n):
	x = int(input())
	f = 1
	j = 1
	while j <= x:
		f *= j
		j += 1
	print(f)


t = int(input())
for i in range(t):
	n = int(input())
	if n == 0 or n == 1:
		print('1')
	else:
		fact = 1
		while n > 0:
			fact = fact * n
			n = n - 1
		print(fact)


import math
x = int(input())
for i in range(x):
	print(math.factorial(int(input())))