I have to program a calculation of pi in BASIC. To do so, i use the FOR ... TO ... STEP
construction of BASIC.
Also, i am using 2 NEXT
commands, the last one fails. It looks like it only fails as the programm reached the limit of the loop.
My code looks like this:
2040 LET M = 0
2050 LET P = 3
2070 FOR i = 1 TO 50 STEP 2
2075 IF M = 1 THEN 2100
2080 P = P + 4/(I*(I+2)*(I+3))
2085 M = 1
2089 PRINT P
2090 NEXT i
2100 P = P - 4/(I*(I+2)*(I+3))
2105 M = 0
2109 PRINT P
2110 NEXT i
The Excpected Result is a list like this:
3.2981943981943984
3.2994764494764497
3.2986049897814604
3.2992241848279003
3.2987685001616893
and so on...
The error i get (only if i
reached 50):
next without for in line 2110
Or, at another environment
E6 at 2110 FOR/NEXT error
I dont find very much helpful documentation on the Web, only the basic FOR ... TO ... STEP ... NEXT
.