So let me start with how this program obtains factorials. Let's focus on Section B1:
Remember that this loop's variable i will obtain values from 1 to 10; so the first time the loop executes i = 1, then i = 2, i = 3, and so on.
First Loop Iteration:
Before Loop:
i = 1
factorialFor_i = 1
During Loop:
factorialFor_i *= i; // Multiply factorial by i (1)
so 1*1 = 1
Result:
i = 1, factorialFor_i = 1
Second Loop:
Before Loop:
i = 2
factorialFor_i = 1
During Loop:
factorialFor_i *= i; // Multiply factorial by i (2)
1*2 = 2
Result:
i = 2, factorialFor_i = 2
Third Loop:
Before Loop:
i = 3
factorialFor_i = 2
During Loop:
factorialFor_i *= i; // Multiply factorial by i (2)
2*3 = 6
Result:
i = 3, factorialFor_i = 6
Simple right? Now termSum and factorialSum work the same way.... just step through the loop and see that the values you get are right where you want them. It would be very useful to step through the code in a debugger (if you have been introduced to debuggers, they make life a bit easier by stepping through your code and showing the values for all the variables just like I did here.
I hope this helps! Let me know if you need any more clarification.
Ed