I wrote a program that will use synthetic division to check all of the possible rational roots of a polynomial and display which are actual roots, as well as the quotient after dividing with that root. It works perfectly for all quadratics and cubics I've tested (with only rational roots), but I cannot get it to work on quartics or higher for some reason. Can someone help me out?
As a side note, I'm fairly new to coding; I've been teaching myself for years and only recently started looking up the more advanced stuff. If there are possible improvements in my code, I would appreciate hearing those.
:1→N
:2→O
:ClrAllLists
:ClrHome
:Input "DEGREE:",D
:For(I,0,D
:ClrHome
:Disp "X^
:Output(1,3,D-I
:Output(1,5,"TERM
:Input ":",A
:A→L₁(I+1
:End
:ClrHome
:Disp "QUOTIENTS ROOTS
:L₁(1→A
:Ans→L₄(1
:abs(L₁(D+1→B
:For(I,1,B
:If B/I=iPart(B/I
:Then
:B/I→L₂(N
:N+1→N
:End
:End
:1→N
:For(I,1,A
:If A/I=iPart(A/I
:Then
:A/I→L₃(N
:N+1→N
:End
:End
:dim(L₂ →L
:dim(L₃→M
:For(I,1,L
:For(J,1,M
:L₂ (I)/L₃(J→S
:L₁(1→N
:For(K,2,D+1
:L₁(K)+SN→N
:Ans→L₄(K
:End
:If not(L₄(D+1
:Then
:Disp S▶Frac
:Output(O,1,L₄
:O+1→O
:End
:L₁(1→N
:For(K,2,D+1
:L₁(K)-SN→N
:Ans→L₄(K
:End
:If not(L₄(D+1
:Then
:Disp -S▶Frac
:Output(O,1,L₄
:End
:End
:End