Question: result storage of for loop


I have a question on result storage of for loop.  The program in attached.

The program is relative complex, it is not necessary to look part 1.

The question is in part 2.

The result I proposed is:


but, the real result of r is:


what should I do to modify the program?

Thank you for helping.

Please Wait...