Here's my code:

**Code:** ```
Lbl 0
```

ClrHome

Menu("OPTIONS","ROW#",A,"BIONOMIAL THEOREM",B,"QUIT",C

Lbl A

Output(10,1,"ROW#≤69

Input "ROW:",C

If C≥70:Then

Output(10,15,"ERROR

Goto A

End

seq(C nCr X,X,0,C)→L₆

Disp L₆

Pause

Goto 0

Lbl B

ClrHome

0→D:1→K:1→Z:1→Y

"+→Str0

"X^→Str9

Output(4,1,"D(X+A)^B

Output(5,1,"B≤69

Input "A=",A

Input "B=",B

Input "D=",D

If B≥70:Then

Output(10,1,"ERROR

Goto B

End

If D=0:Then

Output(4,1,"EQUALS ZERO

Pause

Goto B

End

If D≠1:Goto 1

ClrHome

For(Q,0,B

(B!)/(Q!((B-Q)!))→N

Q-K→J

N(A^Q)→G

A^B→H

Fix 6

{0,1,2}→L₁

seq(BX²+JX+H,X,0,2,1→L₂

seq(JX²+HX+B,X,0,2,1→L₃

seq(HX²+BX+J,X,0,2,1→L₄

QuadReg Y₁

QuadReg L₁,L₃,Y₂

QuadReg L₁,L₄,Y₃

{0,1}→L₁

{0,J}→L₂

{0,H}→L₃

{0,B}→L₄

LinReg(ax+b) Y₄

LinReg(ax+b) L₁,L₃,Y₅

LinReg(ax+b) L₁,L₄,Y₆

EquString(Y₁,Str1

EquString(Y₂,Str2

EquString(Y₃,Str3

EquString(Y₄,Str4

EquString(Y₅,Str5

EquString(Y₆,Str6

sub(Str4,1,length(Str4)-3→Str4

sub(Str5,1,length(Str5)-3→Str5

sub(Str6,1,length(Str6)-3→Str6

sub(Str1,1,length(Str1)-(length(Str4)+length(Str5)+6)→Str1

sub(Str2,1,length(Str2)-(length(Str5)+length(Str6)+6)→Str2

sub(Str3,1,length(Str3)-(length(Str6)+length(Str4)+6)→Str3

If G≠1:Then

{0,G}→L₂

LinReg(ax+b) L₁,L₂,Y₁

EquString(Y₁,Str7

sub(Str7,1,length(Str7)-3→Str7

End

If B<20:Then

If not(Q):Then

Output(1,1,Str9+Str1

Y+length(Str9+Str1→Y

End

If Q=B:Output(Z,Y,Str0+Str3

If Q and Q≠B:Then

If (A^Q):Then

Output(Z,Y,Str0+Str7+Str9+Str2

K+1→K:Y+length(Str0+Str7+Str9+Str2→Y

End

If not(A^Q):Goto E

End:End

If B≥20:Then

If not(Q):Then

Output(1,1,Str9+Str1

Y+length(Str9+Str1→Y

End

If Q=B:Output(Z,Y,Str0+Str3

If Q and Q≠B:Then

If (A^Q):Then

Output(Z,Y,Str0+Str7+Str9+Str2

K+1→K:Y+length(Str0+Str7+Str9+Str2→Y

End

If not(A^Q):Goto E

End

If fPart(Z/10)=9:Then

Pause

10:Asm(prgmSHFTUP

1→Z

End

If Y>26:Then

(Y-26)+1→Y:Z+1→Z

End:End

Lbl E

Output(Z+1,1,"DONE

Pause

Float

Goto 0

Lbl 1

ClrHome

For(Q,0,B

(B!)/(Q!((B-Q)!))→N

Q-K→J

DN(A^Q)→G

D(A^B)→H

Fix 6

{0,1,2}→L₁

seq(BX²+JX+H,X,0,2,1→L₂

seq(JX²+HX+B,X,0,2,1→L₃

seq(HX²+BX+J,X,0,2,1→L₄

QuadReg Y₁

QuadReg L₁,L₃,Y₂

QuadReg L₁,L₄,Y₃

{0,1}→L₁

{0,J}→L₂

{0,H}→L₃

{0,B}→L₄

{0,D}→L₅

LinReg(ax+b) Y₄

LinReg(ax+b) L₁,L₃,Y₅

LinReg(ax+b) L₁,L₄,Y₆

LinReg(ax+b) L₁,L₅,Y₇

EquString(Y₁,Str1

EquString(Y₂,Str2

EquString(Y₃,Str3

EquString(Y₄,Str4

EquString(Y₅,Str5

EquString(Y₆,Str6

EquString(Y₇,Str7

sub(Str4,1,length(Str4)-3→Str4

sub(Str5,1,length(Str5)-3→Str5

sub(Str6,1,length(Str6)-3→Str6

sub(Str1,1,length(Str1)-(length(Str4)+length(Str5)+5)→Str1

sub(Str2,1,length(Str2)-(length(Str5)+length(Str6)+5)→Str2

sub(Str3,1,length(Str3)-(length(Str6)+length(Str4)+5)→Str3

If G≠1:Then

{0,G}→L₂

LinReg(ax+b) L₁,L₂,Y₁

EquString(Y₁,Str8

sub(Str8,1,length(Str8)-3→Str8

End

If B<20:Then

If not(Q):Then

Output(1,1,Str7+Str9+Str1

Y+length(Str9+Str1→Y

End

If Q=B:Output(Z,Y,Str0+Str3

If Q and Q≠B:Then

If (A^Q):Then

Output(Z,Y,Str0+Str8+Str9+Str2

K+1→K:Y+length(Str0+Str8+Str9+Str2→Y

End

If not(A^Q):Goto F

End:End

If B≥20:Then

If not(Q):Then

Output(1,1,Str7+Str9+Str1

Y+length(Str9+Str1→Y

End

If Q=B:Output(Z,Y,Str0+Str3

If Q and Q≠B:Then

If (A^Q):Then

Output(Z,Y,Str0+Str8+Str9+Str2

K+1→K:Y+length(Str0+Str8+Str9+Str2→Y

End

If not(A^Q):Goto F

End

If fPart(Z/10)=9:Then

Pause

10:Asm(prgmSHFTUP

1→Z

End

If Y>26:Then

(Y-26)+1→Y:Z+1→Z

End:End

Lbl F

Output(Z+1,1,"DONE

Pause

Float

Goto 0

Lbl C

Float

It's error free as far as I know. However, if I run it and click Binomial Theorem, with A=5,B=2,D=1, it should come out with X^2+10X+25 right? Nope, it just prints X^2. And Q=0 at the end. I don't understand why.

Help me find my error. Any optimization ideas are welcome because this is a lot of code. Thanks.