from typing import Sequence


def from_factorial_base(digits: Sequence[int]) -> int:
    """Inverse of `to_factorial_base`"""
    n = 0
    base = 1
    for i, d in enumerate(reversed(digits), start=1):
        if not (0 <= d <= i):
            raise ValueError(digits)
        n += d * base
        base *= i + 1
    return n