def fib_dp(n):
    """
    An optimized dynamic programming solution to find a single number of the
    Fibonacci sequence. It runs in O(n) time with O(1) space complexity.
    """
    if not isinstance(n, int):
        raise TypeError("n must be an int")
    if n < 0:
        raise ValueError("n must be non-negative")
    f0, f1 = 0, 1
    for _ in range(n):
        f0, f1 = f1, f0 + f1
    return f0