def factorial_tabulation(n):
    """Tabulation implementation of factorial: O(n) runtime, O(n) space"""
    d = [0] * (n + 1)
    d[0] = 1
    # could alternatively have base case of d[1] = 1 and compute d[n] from there, looping from i = 2
    for i in range(1, n + 1):
        d[i] = i * d[i - 1]
    return d[n]