15,119,363 members
1.00/5 (1 vote)
See more:
```Dear all,

I would like to write a formula consist of summation.

G(i) = m + sigma (j=0 to i-1) G(j) * m

in each level to calculate new G we have to use previous calculated Gs. for example:
for G(3) we need (G(0)*m + G(1)*m + G(2)*m) which have calculated in previous levels. And m is a constant(18.01).

I would like to write a code for this loop (data numbers come from a column in a text file) But as I am beginner to python I dont know how to start. Do I have to use more than one loop? a loop for G(i) and a loop for sigma? what can be the exact form?

What I have tried:

`I tried simple codes for summation but I have no idea for this problem. `
Posted
Updated 22-Oct-21 7:46am

## Solution 1

Use a list to store each value of G, and a loop index to get the previous values. See 3. An Informal Introduction to Python — Python 3.9.7 documentation[^]. Or maybe better to start at The Python Tutorial — Python 3.9.7 documentation[^].

Dear Richard