Skip to content

Instantly share code, notes, and snippets.

@Nil-Zil Nil-Zil/
Created Jan 19, 2018

What would you like to do?
#!/usr/bin/env python3
# created at Jun 3, 2017 01:19 by Nil-Zil
class Factorial(object):
def factorial_recur(self, n):
if n is 1:
return 1
# recursive, but not tail recursive
return n * self.factorial_recur(n - 1)
def factorial_iter(self, n, prod):
if n is 1:
return prod
return self.factorial_iter(n - 1, n * prod)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.