A series is a continuing sum of terms that have a pattern. It can be very useful to know how to code a program to computer a series.
For example, we can add up a series of numbers using the following code:
int sum = 0;
for(int i = 0; i < 10; i++) {
sum += i+1;
} //finds the sum of the first 10 whole numbers (1, 2, 3...)
We can also use it to find a more complicated series:
//find the sum of the series 1+1/2+1/4+1/8+1/16+1/32... to the 10th term
for(int i = 0; i < 10; i*=2) {
sum += 1/(i^2+1);
}
We also have a handy loop known as a while loop. This runs until a condition is false.
while(condition) {
doSomething();
}
if the condition will always be true, then the loop may run infinitely.
We then went over lots of practice problems involving loops.
Solution: https://replit.com/@offexe/12-15hw