<gh_stars>0
# Write and test a recursive function factorial(n) that 
# returns n! (factorial of n). The function must raise 
# ValueError if its argument is not a positive integer

def factorial(n):
    try:
        if n<0:
            raise Exception
        elif n == 1 or n == 0:
            return 1
        else:
            return n*factorial(n-1)
    except Exception:
        print("non posso calcolare il fattoriale di un numero negativo\nmi dispiace!!!!!!!!")
        return None
nn = int(input("inserire un numero: "))
print("il fattoriale di",nn," è:")
print(factorial(nn))
# Write and test a recursive function factorial(n) that 
# returns n! (factorial of n). The function must raise 
# ValueError if its argument is not a positive integer

def factorial(n):
    try:
        if n<0:
            raise Exception
        elif n == 1 or n == 0:
            return 1
        else:
            return n*factorial(n-1)
    except Exception:
        print("non posso calcolare il fattoriale di un numero negativo\nmi dispiace!!!!!!!!")
        return None
nn = int(input("inserire un numero: "))
print("il fattoriale di",nn," è:")
print(factorial(nn))
# Write and test a recursive function factorial(n) that # returns n! (factorial of n). The function must raise # ValueError if its argument is not a positive integer