For k= 1 to j- 1

x= x+1

Next k

Just adds 1 to x j-1 times: the result is x+ j-1- it just adds j- 1 to x.

And it does that for j running form 1 to i-1: That is, we will have x+ 1+ 2+ 3+ ...+ i-2. it is well know that \(\displaystyle 1+ 2+ \cdot\cdot\cdot+ n= \frac{n(n+1)}{2}\) so the result of the j loop will be x+ \frac{(i-1)i){2}[/tex]. (These are the "triangular numbers" 1, 3, 6, 10, ...)

Now, it does that for i going from i to 200 so it will be x+ 1+ 3+ 6... and the result will be x plus the sum of the first 199 (because it is "i-1", not "i" in the formula) triangular numbers.

To get those, look at \(\displaystyle \frac{i(i+1)}{2}= \frac{i^2+ i}{2}= \frac{n^2}{2}+ \frac{n}{2}\).

\(\displaystyle \sum{i=1}^n \frac{i}{2}= \frac{1}\sum i\) is easy- it is just 1/2 the sum above- \(\displaystyle \frac{n(n+1)}{4}\).

And \(\displaystyle \sum{n^2}\) is also well known: it is \(\displaystyle \frac{n(n+1)(2n+1)}{6}\)

I agree with TKHunny- it is peculiar that x is not initialized- without knowing its initial value we cannot know what the result is. I'ts been a long time since I programmed with Basic- and never with "Visual Basic" but in the dark, distant past, some versions of Basic assumed initial values of 0 (a really bad practice!). Is that still true?