How would I write this piece of pseudocode in mathematical notation?

1.1k Views Asked by At

I am trying to figure out how to write the summation of a function, $f(t)$, on an interval as mathematical notation. I can only think of the answer in terms of pseudocode, can anyone help me convert the following into mathematical notation?

x = f(0) for (int i = 1; i <= 7; i++) { x(i) = x + f(i); }

Thanks!

edit: Sorry I asked this question wrong. I meant it to be written as each iteration denotes a new value. So, in the case of my problem f(t) is a function of time in days. I want the values to equal the following:

day0 = $f(0)$

day1 = $f(0) + f(1)$

day2 = $f(0) + f(1) + f(2)$

day3 = $f(0) + f(1) + f(2) + f(3)$

day4 = $f(0) + f(1) + f(2) + f(3) + f(4) $

day5 = $f(0) + f(1) + f(2) + f(3) + f(4) + f(5)$

day6 = $f(0) + f(1) + f(2) + f(3) + f(4) + f(5) + f(6)$

day7 = $f(0) + f(1) + f(2) + f(3) + f(4) + f(5) + f(6) + f(7)$

days 8 $\rightarrow \infty$ = $f(0) + f(1) + f(2) + f(3) + f(4) + f(5) + f(6) + f(7)$

1

There are 1 best solutions below

1
On BEST ANSWER

Using a for-loop, you are summing up $f(0)$ up to $f(7)$. The pseudo-code is describing $$x=\sum_{i=0}^7 f(i)$$

Edit:

For the edited question:

$$day_i = \sum_{j=0}^{\min(i,7)} f(j)$$