def factorial(n): assert type(n) == int, "Invalid input type" assert n >= 0, "Input must be non-negative" if n <= 1: return n else: return n*factorial(n-1)