I have a task to write a program which for a sequence number as a result give a geometric mean. I have to write this program without any package. The introduction of the program end, when users give a 0. The program should report an error if the first number is 0 and if the user gives a negative number.
def sequence():
prod=1
i=-1
x=1
n = int(input("Give a number: "))
while True:
if n == 0:
break
elif i==0:
print("Error")
else:
prod=prod*n
i=i+1
result=prod**(1/i)
print(" Średnia wartośc ciągu ", result)
return i, suma
sequence()
My program doesn't return anything.