@emptymalei/

recursive-iterative

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def recursiveFactorial(n):
	if n == 0:
		return 1
	else:
		return n * recursiveFactorial(n - 1)


def iterativeFactorial(n):
	ans = 1

	i = 1

	while i <= n:
		ans = ans * i
		i = i + 1

	return ans


print(recursiveFactorial(0))
print(iterativeFactorial(0))