I get an error at the 'Else' on a TI-84 Plus. I can't figure out why this doesn't work.
I'm writing a GCD program just as an exercise in programming a TI calculator. It's recursive (or as recursive as TI-BASIC gets).
If B=0
Disp A
Else
C->B
B->remainder(A,B)
A->B
prgmGCD2
TI-Basic is often rather picky about the syntax of if statements.
There are three general formats for an If statement.
:If <boolean>
:<expression>
Note that <expression>
consists of exactly one line of code.
:If <boolean>
:Then
:<expresion>
:<expresion>
:End
As opposed to the first option, this option can contain any number of lines of code after the If
.
:If <boolean>
:Then
:<expresion>
:<expresion>
:Else
:<expresion>
:<expresion>
:End
As with the previous option, any number of statements can be put after the If
and after the Else
.
You are obviously trying to use an if else statement. The correct syntax for this is:
:If B
:Then
:C->B
:B->remainder(A,B)
:A->B
:prgmGCD2
:Else
:Disp A
:End