current position:Home>Solve input m calculation results, solve

Solve input m calculation results, solve

2022-02-02 20:00:57 CSDN Q & A

Programming requirements : 1-1/2+1/3-1/4+1/+5....+ (-1)n-1/n. Enter... In the source program m Value calculation results of .( among n The value of is not less than 8)
solve Just a little simpler

Refer to the answer 1:
inner = int(input())s = 0for i in range(1, inner+1):    s = s + 1 / (i * ((-1)**(i+1)))print(s)

Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended