I'm trying to determine the proper notation for the following loop I have written in computer code:
Set x = 2 set y = 3
For z=1 to z=5 (increasing the value of z by 1 each iteration):
set x = x * y
set y = y + zSolve for X
This should yield a result of x = 16848 --is there a nice way to write this loop in mathematical notation? I've thought of using summations and the capital Pi symbol, but neither seem to quite do the trick...
Mathematical notation handles this kind of thing by giving a separate name to the value of $x$ and $y$ at each state of the computation. The names $x_0$ and $y_0$ refer to the initial states of $x$ and $y$, and then for each iteration, we compute the new values $x_{n+1}$ and $y_{n+1}$ in terms of the current values $x_n$ and $y_n$, something like this:
$$\begin{align} x_0 & = 2 & y_0 & = 3 \\ x_{n+1} & = x_n y_n & y_{n+1} & = y_n + n & \text{for $n\in[1,\ldots,5]$} \end{align}$$
And then the question becomes, what is the value of $x_5$?
This does have the benefit that it makes completely clear exactly what is being computed at each step. If we were to exchange the order of the $x\leftarrow xy$ and $y\leftarrow y+n$ steps, so that $y$ was updated before $x$, this would be reflected in the notation above as $x_{n+1}=x_ny_{\color{red}{n+1}}$ instead of $x_{n+1}=x_ny_n$.