0
$\begingroup$

I want to create equation that represents following piece of code (it is much more complicated I simplify it for clearance)

int v = 23; sum = 0; for (int i = v; i > 0; i= i - 2) { sum = sum + i; }

I want to write it like

\sum^{i=i-2;i>0}_{i=v}i

but I have feeling that it might not be the proper way.

  • 1
    I need to put in an math article and it must be in a form of equation.2011-04-07

1 Answers 1

3

For a finite sum, the order isn't important, and I don't think I have seen a sum where the order was specified as in a for loop.

You can write multiple conditions which have to be satisfied below the $\sum$. For example,

$\sum_{\substack{p ~\text{prime} \\ p \equiv 1 \pmod 4}} \frac{1}{p^2}.$

Your sum might be written as

$\sum_{\substack{0\lt i \le v \\ v-i ~ \text{is even}}} i.$