为什么输出不对,python求助各位大佬!!

P1035 [NOIP2002 普及组] 级数求和

little_q_exist @ 2024-08-14 17:17:48

def cal_item(n):
    return 1/n

k = int(input())
n = 1
Sn = 0
while Sn <= k:
    n += 1
    Sn += cal_item(n)
else:
    print(n)

by lihaolin060942 @ 2024-08-25 11:38:43

我也不明白


by zhaolianghan @ 2024-08-31 10:05:03

num=int(input())
i=0
s=0
while s<=num:
    i+=1
    s+=1/i
print(i)

拿去,不谢


by little_q_exist @ 2024-09-01 10:59:37

@zhaolianghan 感谢


|