Why is it saying that there is a syntax error for the if/else statement I wrote?

前端 未结 1 1239
一生所求
一生所求 2021-01-28 13:18

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)

El         


        
相关标签:
1条回答
  • 2021-01-28 14:17

    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.

    0 讨论(0)
提交回复
热议问题