There is a famous legend of a student misbehaving in class back in the late 1700s. For punishment, the teacher made
him add up all of the number between 1 and 100. To the teacher's surprise, the student did it in seconds. The student
was the (now) famous mathematician Carl Gauss. For loops can easily add up sequences of numbers. Let's
repeat Gauss's punishment here with a for loop. Gauss's famous formula for adding numbers from $1$ to some number $n$ is $S_n=n(1+n)/2$.
This formula might be in your math book.
Now you try. Use a for loop and a separate variable called sum to add up the numbers between 1 and 100.
Type your code here:
See your results here:
The code will not run as is! You have to look carefully at the for i=, do line and fix it
to cause the variable i to run between 1 and 100. Can you do it?
Share your code
Show a friend, family member, or teacher what you've done!