liouville lambda function the liouville lambda function denoted by n and n is 1 if n is the product of an even number of prime numbers and 1 if it is the product of an odd number of primes https en wikipedia orgwikiliouvillefunction akshay dubey https github comitsakshaydubey this functions takes an integer number as input returns 1 if n has even number of prime factors and 1 otherwise liouvillelambda10 1 liouvillelambda11 1 liouvillelambda0 traceback most recent call last valueerror input must be a positive integer liouvillelambda1 traceback most recent call last valueerror input must be a positive integer liouvillelambda11 0 traceback most recent call last typeerror input value of number11 0 must be an integer akshay dubey https github com itsakshaydubey this functions takes an integer number as input returns 1 if n has even number of prime factors and 1 otherwise liouville_lambda 10 1 liouville_lambda 11 1 liouville_lambda 0 traceback most recent call last valueerror input must be a positive integer liouville_lambda 1 traceback most recent call last valueerror input must be a positive integer liouville_lambda 11 0 traceback most recent call last typeerror input value of number 11 0 must be an integer
from maths.prime_factors import prime_factors


def liouville_lambda(number: int) -> int:
    
    if not isinstance(number, int):
        msg = f"Input value of [number={number}] must be an integer"
        raise TypeError(msg)
    if number < 1:
        raise ValueError("Input must be a positive integer")
    return -1 if len(prime_factors(number)) % 2 else 1


if __name__ == "__main__":
    import doctest

    doctest.testmod()