@emptymalei/

recursive-iterative

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5274033462867194","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"ZGVmIHJlY3Vyc2l2ZUZhY3RvcmlhbChuKToKCWlmIG4gPT0gMDoKCQlyZXR1cm4gMQoJZWxzZToKCQlyZXR1cm4gbiAqIHJlY3Vyc2l2ZUZhY3RvcmlhbChuIC0gMSkKCgpkZWYgaXRlcmF0aXZlRmFjdG9yaWFsKG4pOgoJYW5zID0gMQoKCWkgPSAxCgoJd2hpbGUgaSA8PSBuOgoJCWFucyA9IGFucyAqIGkKCQlpID0gaSArIDEKCglyZXR1cm4gYW5zCgoKcHJpbnQocmVjdXJzaXZlRmFjdG9yaWFsKDApKQpwcmludChpdGVyYXRpdmVGYWN0b3JpYWwoMCkpCg=="},"asBuffer":null},"loaded":true}}
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))