twin prime a number n2 is said to be a twin prime of number n if both n and n2 are prime examples of twin pairs 3 5 5 7 11 13 17 19 29 31 41 43 https en wikipedia orgwikitwinprime akshay dubey https github comitsakshaydubey doctest normalizewhitespace this functions takes an integer number as input returns n2 if n and n2 are prime numbers and 1 otherwise twinprime3 5 twinprime4 1 twinprime5 7 twinprime17 19 twinprime0 1 twinprime6 0 traceback most recent call last typeerror input value of number6 0 must be an integer akshay dubey https github com itsakshaydubey doctest normalize_whitespace this functions takes an integer number as input returns n 2 if n and n 2 are prime numbers and 1 otherwise twin_prime 3 5 twin_prime 4 1 twin_prime 5 7 twin_prime 17 19 twin_prime 0 1 twin_prime 6 0 traceback most recent call last typeerror input value of number 6 0 must be an integer
from maths.prime_check import is_prime


def twin_prime(number: int) -> int:
    
    if not isinstance(number, int):
        msg = f"Input value of [number={number}] must be an integer"
        raise TypeError(msg)
    if is_prime(number) and is_prime(number + 2):
        return number + 2
    else:
        return -1


if __name__ == "__main__":
    import doctest

    doctest.testmod()