Skip to content

Instantly share code, notes, and snippets.

@kiler129
Created October 21, 2018 05:24
Show Gist options
  • Save kiler129/94396586826afe438aa4aa12020272e4 to your computer and use it in GitHub Desktop.
Save kiler129/94396586826afe438aa4aa12020272e4 to your computer and use it in GitHub Desktop.
Rational Zero Theorem implementation in TI-Basic
Define rzt(l,c)=
Prgm
: If l=0 Then
: Disp "ERR:l=0"
: Stop
: EndIf
: If c=0 Then
: Disp "ERR:c=0"
: Stop
: EndIf
: If l<0
: l*−1→l
: If c<0
: c*−1→c
: If fPart(l)≠0 Then
: Disp "l∉ℤ"
: Stop
: EndIf
: If fPart(c)≠0 Then
: Disp "c∉ℤ"
: Stop
: EndIf
:
:
: Local p,q,r,f,i
: r:={}
: For q,1,l
: If remain(l,q)≠0
: Goto ole
: For p,1,c
: If remain(c,p)≠0
: Goto ile
: ±factor(((p)/(q)))→f
: If dim(r)>0 Then
: For i,1,dim(r)
: If r[i]=f
: Goto ile
: EndFor
: EndIf
: f→r[dim(r)+1]
: Lbl ile
: EndFor
: Lbl ole
: EndFor
: SortA r
: Disp r
:EndPrgm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment