Skip to content

Commit 1a446a3

Browse files
authored
Create series_sum.py
1 parent 6031614 commit 1a446a3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

series_sum.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Starting Out with Python (4th Edition).
2+
# Tony Gaddis.
3+
# Page 225.
4+
# 5. A loop which calculates the series sum of 1/30 + 2/29 + 3/28 + ... + 30/1
5+
6+
num = 1 # Numerator of First Term.
7+
den = 30 # Denominator of First Term.
8+
sum = 0.0
9+
10+
for x in range(31):
11+
num = x
12+
den = 30-x+1
13+
sum += num/den
14+
print("Sum = ", format(sum, '.36f'))

0 commit comments

Comments
 (0)