S Av 1.3.5 Sumatorio
while True:
try:
N = int(input("Introduir valor enter: "))
if N <= 0:
print("Error: el valor ha de ser més gran que zero")
else:
break
except ValueError:
print("Error: Introdueix un valor enter positiu vàlid.")
suma = sum(range(1, N + 1))
print(f"El sumatori de {N} és: {suma}")
Comentarios
Publicar un comentario