def test1(n): i = 0 s = 0.0 for i in range(2, n + 1, 2): s += 1.0 / i return s def test2(n): s = 0.0 for i in range(1, n + 1, 2): s += 1 / i return s while True: if __name__ == '__main__': n = int(input("请输入一个正整数:")) if n % 2 == 0: print(test1(n)) else: print(test2(n))
def test1(n): i = 0 s = 0.0 for i in range(2, n + 1, 2): s += 1.0 / i return sdef test2(n): s = 0.0 for i in range(1, n + 1, 2): s += 1 / i return swhile ...