Oct-07-2017, 09:03 PM
I am trying to create a function that return the sumer of the following series 1000 +1/1^2 + 1/2^2 ... and so on for the given integer n.
So far I have:
Im not sure what is wrong with my code? Can someone please help me and tell me what is wrong?
So far I have:
def series_sum(): n= int (input('Please enter a non-negative integer: ')) if n<0: return None else: c= 1000 for i in range(1,n+1): c=c+(1/i**2) return cBut it returns 1001 instead of 1001.25 when you input n=2
Im not sure what is wrong with my code? Can someone please help me and tell me what is wrong?