calculates the nth number in sylvester s sequence source https en wikipedia orgwikisylvester27ssequence param number nth number to calculate in the sequence return the nth number in sylvester s sequence sylvester8 113423713055421844361000443 sylvester1 traceback most recent call last valueerror the input value of n1 has to be 0 sylvester8 0 traceback most recent call last assertionerror the input value of n8 0 is not an integer param number nth number to calculate in the sequence return the nth number in sylvester s sequence sylvester 8 113423713055421844361000443 sylvester 1 traceback most recent call last valueerror the input value of n 1 has to be 0 sylvester 8 0 traceback most recent call last assertionerror the input value of n 8 0 is not an integer
def sylvester(number: int) -> int:
    
    assert isinstance(number, int), f"The input value of [n={number}] is not an integer"

    if number == 1:
        return 2
    elif number < 1:
        msg = f"The input value of [n={number}] has to be > 0"
        raise ValueError(msg)
    else:
        num = sylvester(number - 1)
        lower = num - 1
        upper = num
        return lower * upper + 1


if __name__ == "__main__":
    print(f"The 8th number in Sylvester's sequence: {sylvester(8)}")