def fun(n): L1=[1/((x+1)*(x+2)) for x in range(0,n,2)] L2=[-1/((x+1)*(x+2)) for x in range(1,n,2)] return sum(L1)+sum(L2)def main(): n=int(input("请输入n的值")) print("sum=",fun(n))main()