We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6031614 commit 1a446a3Copy full SHA for 1a446a3
series_sum.py
@@ -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