Hacker News new | ask | show | jobs
by Sharlin 4422 days ago
I believe the following is a corecursive analog for a stack recursive factorial implementation in Python:

    def factorial(i = 1):
        yield i
        for j in factorial(i + 1):
            yield j*i
Not sure why anyone would want to implement it like that, though.