Hi again! I'm having problems fixing some bugs in my Ruffini's rule program.

Its objective is to make the integer division of a polynomial, having as the divider a polynom of the type (x-alpha) with alpha as a constant, by applying Ruffini's rule.

As an input:

- alpha in (x-alpha) divider polynomial

- the degree of the polynomial being divided

- the coefficients of the polynomial being divided

As an output:

- alpha again

- the resulting polynomial

- the rest of the division

```
ClrHome
Input "ALPHA=",D //in (x-alpha), indicate alpha
Disp "DEGREE<10
Input "DEGREE:",G //indicate the degree of the polynomial
Disp "ORDER BY DEGREE
G+1->G
SetUpEditor L3
G->dim(L3
For(N,1,G
Input A //input the coeficients of the polynomial by decreasing order of degree to which it is associated
A->L3(N //storing it to L3
End
SetUpEditor L4
G->dim(L4
L3(1->L4(1
For(N,2,G
DL4(N-1)+L3(N)->L4(N //aplying Ruffini's law and storing results to L4
End
"?->Str0
For(N,1,G-1 //turning the values of L4 into a string to be displayed
If L4(N)>=0 and N!=1
Str0+"+->Str0
{0,1->L1
{0,L4(N->L2
LinReg(ax+b) {Y1}
Equ>String({Y1},Str1
Str0+sub(Str1,1,length(Str1)-3->Str0
If G-N>1
Ans+"X->Str0
If G-N>2
Then
{0,G-1-N->L2
LinReg(ax+b) {Y2}
Equ>String({Y2},Str2
Str0+"^"+sub(Str2,1,length(Str2)-3->Str0
End
End
ClrHome
2->N
Repeat N>=length(Str0 //remove and change stuff, making it a correct mathematical expression
If sub(Str0,N,1)="~" and sub(Str0,N-1,1)!="^
sub(Str0,1,N-1)+"-"+sub(Str0,N+1,(length(Str0)-N->Str0 //change - by ~ when needed
sub(Str0,N-1,1
If sub(Str0,N,2)="0X" and Ans="+
Then
sub(Str0,1,N-2)+sub(Str0,N+4,(length(Str0)-N-3->Str0 //deleting monomials of the type 0x^n
N-1->N
End
sub(Str0,N-1,1
If sub(Str0,N,2)="1X" and (Ans="+" or Ans="-" or Ans="?
Then
sub(Str0,1,N-1)+sub(Str0,N+1,length(Str0)-N-1->Str0 // deleting the number "1" in monomials of the type 1x^n
N-1->N
End
N+1->N
End
Output(1,1,"ALPHA=
Output(1,7,D //displaying alpha
Output(3,1,"Q(X)=
sub(Str0,2,length(Str0)-1->Str0 //taking off the "?"
Output(3,6,Str0 //displaying the polynomial
Output(6,1,"R=
Output(6,3,L4(G //displaying the rest of the division
Output(8,1,"CHECK 'Y=' MENU
Pause
String>Equ(Str0,{Y1} //makes Str0 into an equation in the Y= menu
Pause
ClrHome
DelVar ADelVar DDelVar GDelVar NDelVar XDelVar Str0DelVar Str1DelVar Str2DelVar {Y2} //deleting stuff
ClrList L1
ClrList L2
ClrList L3
ClrList L4
ClrList |LRESID
```

So the problem is: for some divisions, it bugs.

for example: dividing x^3-3x^2-4x+1/2 by x-2

in this case, alpha is 2, the degree is 3 and the input is to be made as follows: 1 , (enter), ~3, (enter), ~4, (enter), 1/2

then just enter and it takes off.

the math is correctly made (as confirmed if you recall L4), but the expression is incorrect

it also bugs with some other divisions aswell.

can you help me solving this issue? i'm taken to believe the error occurs in the final Repeat loop, the one that corrects stuff.

I had 1 more question btw

does it pay off if you use finance variables instead of real ones for improving gaming speed?

That's all for now, thanks