I have a simple while loop. After running, the variable does not change:
a=1;
b=2;
v1 = NSolve[a^2 == E^(-(x/b))/x, x, Real][[1]];
f[x_] := x;
v = f[x /. v1]
v=5.72178
I use above value of v as intial value of v in the while loop:
i = 1; v = f[x /. v1];
While[ i < 10, v = v++; i++]
Now, I want to see what is the value of "i" and "v" after running while loop:
?i
i=10
but v is not changed:
?v
v=5.72178
why "v" doesn't change? What should I do?
v++
orv=v+1
. Not both. $\endgroup$ – AccidentalFourierTransform Jun 27 at 23:10v=++v
if you insist on horrible syntax. This is a good opportunity to learn about what++v
andv++
really mean: pre-increment and post-increment. $\endgroup$ – Roman Jun 28 at 5:52