If I run
"Dim i as Integer = 1
While i <= x
x = x * i
i= i+1
Wend
Return x"
with x = 6 (for example, value passed by a Button) it doesn’t stop when i = 6 but goes on and on.
Anybody knows why?
Thank you
If I run
"Dim i as Integer = 1
While i <= x
x = x * i
i= i+1
Wend
Return x"
with x = 6 (for example, value passed by a Button) it doesn’t stop when i = 6 but goes on and on.
Anybody knows why?
Thank you
x gets bigger faster than i, is the answer.
You can change your code to:
Dim i as Integer = 1
Dim mStop as Integer = x
While i <= mStop
x = x * i
i= i+1
Wend
Return x
Thank you, it worked. Although it muste be; While i < mStop in line 3.
Otherwise you get an error in excess by the amount of x * mStop + 1.
Yes, but mStop does not, and that is the limit