Im making a pyton exercise for my uni homework and can't seem to figure it out. I need to make the sum of 1/n^2, n being a value introduced by the user.
Example:
user puts n=4
Program Calculates: 1+1/4+1/9+1/16= 1.42361111
This is what i have so far:
num = int(input("n: "))
sum = 0
x=1
while x<=num:
sum=1/(x*x)
x=x+1
print ("the sum is:" , sum)