问题
I'm trying to write a program that calculates the sum of a geometric series on a TI-84.
Prompt A
Prompt R
Prompt N
If N=100 and abs(R)<1
Disp (A/1-R)
Else
Disp (A(1-R^N))/(1-r)
It says that there is a syntax error at the Else line.
回答1:
Else
can only be paired with an If .. Then
construct, not a plain If
. So:
Prompt A,R,N
If N=100 and abs(R)<1
Then
Disp A/(1-R
Else
Disp (A(1-R^N))/(1-R
In general the If.. Then .. Else .. End
construct should be closed by End
but in this case the program exits anyway so it makes no difference. There is some documentation of this in the official TI-BASIC manual and you can check out a more detailed version here.
来源:https://stackoverflow.com/questions/55768920/why-is-it-saying-that-there-is-a-syntax-error-for-the-if-else-statement-i-wrote