First, you can make the tail recursive:
def tfact(n,acc=1): if n<=1: return acc else: return tfact(n-1,acc*n)
But for a more direct translation:
def ifact(n): stack = [] while True: if n==1: while stack: n *= stack.pop() break else: stack.append(n) n -= 1 return n
source share