the first known prime found to exceed one million digits was discovered in 1999 and is a mersenne prime of the form 26972593 1 it contains exactly 2 098 960 digits subsequently other mersenne primes of the form 2p 1 have been found which contain more digits however in 2004 there was found a massive nonmersenne prime which contains 2 357 207 digits 28433 2 7830457 1 find the last ten digits of this prime number returns the last n digits of number solution 8739992577 solution8 39992577 solution1 7 solution1 traceback most recent call last valueerror invalid input solution8 3 traceback most recent call last valueerror invalid input solutiona traceback most recent call last valueerror invalid input returns the last n digits of number solution 8739992577 solution 8 39992577 solution 1 7 solution 1 traceback most recent call last valueerror invalid input solution 8 3 traceback most recent call last valueerror invalid input solution a traceback most recent call last valueerror invalid input
def solution(n: int = 10) -> str:
    
    if not isinstance(n, int) or n < 0:
        raise ValueError("Invalid input")
    modulus = 10**n
    number = 28433 * (pow(2, 7830457, modulus)) + 1
    return str(number % modulus)


if __name__ == "__main__":
    from doctest import testmod

    testmod()
    print(f"{solution(10) = }")