sequence, so that any one specific result can be selected among them all, as and when needed. There is a connection with denotational semantics, where the denotations of recursive programs is built up corecursively in this way. In Python, a recursive factorial function can be defined as: def factorial(n: int) -> int: """Recursive factorial function.""" if n == 0: return 1 else: return n * factorial(n - 1) This could then be called for example as factorial(5) to compute 5!. A corresponding corecursive generator can be defined as: def factorials(): """Corecursive generator.""" n, f = 0, 1 while True: yield f n, f = n + 1, f * (n + 1) This generates an infinite stream of factorials in order; a finite portion of it can be produced by: def n_factorials(k: int): n, f = 0, 1 while n <= k: yield f n, f = n + 1, f * (n + 1) This could then be called to produce the factorials up to 5! via: for f in n_factorials(5): print(f) If we're only interested in a certain factorial, just the last value can be taken, or we can fuse the production and the access into one function, def nth_factorial(k: int): n, f = 0, 1 while n < k: n, f = n + 1, f * (n + 1) yield f As can be readily seen here, this is practically equivalent (just by substituting return for the only yield there) to the accumulator argument technique for tail recursion, unwound into an explicit loop. Thus it can be said that the concept of corecursion is an explication of the embodiment of iterative computation processes by recursive definitions, where applicable. Fibonacci sequence In the same way, the Fibonacci sequence can be represented as: Because the Fibonacci sequence is a recurrence relation of order 2, the corecursive relation must track two successive terms, with the corresponding to shift forward by one step, and the corresponding to computing the next term. This can then be implemented as follows (using parallel assignment): def fibonacci_sequence(): a, b = 0, 1 while True: yield a a, b = b, a + b In Haskell, map fst ( (\(a,b) -> (b,a+b)) `iterate` (0,1) ) Tree traversal Tree traversal via a depth-first approach is a classic example of recursion. Dually, breadth-first traversal can very naturally be implemented via corecursion. Without using recursion or corecursion specifically,