Skip to content

Commit 2fd3037

Browse files
committed
typo
1 parent fe5774a commit 2fd3037

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

_sources/Unit4-Iteration/topic-4-5-loop-analysis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ How many stars are printed out? How many times do the loops iterate? The outer l
329329

330330
There is a neat formula to calculate the sum of n natural numbers: ``n(n+1)/2`` where n is the number of times the outer loop runs or the maximum number of times the inner loop runs. So, for the example above, the outer loop runs 5 times (and the inner loop runs 0 to a maximum of 5 times) so for n=5, the inner loop runs 5(5+1)/2 = 15 times.
331331

332-
This summation formula has a great story that goes back to the famous mathematician Carl Gauss. The story goes that when he was in elementary school in the 1780s, his teacher asked the class to add up all the numbers from 1 to 100. Gauss quickly discovered the pattern that the sum of the first and last numbers is 1 + 100 = 101, the sum of the second and second-to-last numbers is 2 + 99 = 101, and so on. So if you write the series 1 to 100 twice and pair things up, you can quickly that you have 100 pairs that sum to 101 and then you can divide by 2 to get down to just 1 series. Gauss's formula for the sum of the first n natural numbers ``n(n+1)/2`` works for any n. Try it with adding up 1 to 5 and 1 to 10 by pairing numbers until you memorize the pattern and the formula.
332+
This summation formula has a great story that goes back to the famous mathematician Carl Gauss. The story goes that when he was in elementary school in the 1780s, his teacher asked the class to add up all the numbers from 1 to 100. Gauss quickly discovered the pattern that the sum of the first and last numbers is 1 + 100 = 101, the sum of the second and second-to-last numbers is 2 + 99 = 101, and so on. So if you write the series 1 to 100 twice and pair things up, you can quickly see that you have 100 pairs that sum to 101 and then you can divide 100*101 by 2 to get down to just 1 series. Gauss's formula for the sum of the first n natural numbers ``n(n+1)/2`` works for any n. Try it with adding up 1 to 5 and 1 to 10 by pairing numbers until you memorize the pattern and the formula.
333333

334334
.. figure:: Figures/sumFormula.png
335335
:width: 400px

0 commit comments

Comments
 (0)