I want to know exactly how many iterations it would take this algorithm to terminate. In other words, is there a closed-form solution for the number of iterations? (For my input values, it is always guaranteed to terminate.)
Let $x$, $y$, and $z$ be some positive integers. The values of $x$, $y$, and $z$ are chosen such that neither $y$ nor $z$ will become $\le 0$ before the loop terminates.
$\text{do}$
$\qquad \text{if } (x+y) \text{ mod } z = 0 \text{ then done}$
$\qquad x \leftarrow x + y$
$\qquad y \leftarrow y - 4$
$\qquad z \leftarrow z - 2$
$\text{loop}$
For example, if we let $x =184$, $y = 376$, and $z = 187$, this algorithm terminates in $19$ loops.
Here is a plot of $(x+y) \text{ mod } z$ for some real inputs. Here is another plot for larger inputs.