编写程序计算sn=1+1/2+1/3+1/4+1/5
时间: 2023-09-12 17:03:10 浏览: 214
求1+1/2+1/3+1/4+…….+1/100的值
Sure, the program to calculate sn=1 1/2 1/3 1/4 1/5 is quite simple. Here's a Python code snippet that computes sn.
```
n = 5
sum_numbers = 0.0
for i in range(1, n+1):
sum_numbers += 1/i
print(sum_numbers)
```
The output will be 2.283333333333333.
阅读全文