:Prompt A,B

:A:prgmC

:"("+Str0+sub("x+x-",1+2(B<0),2→Str1

:B:prgmC

:Str1+Str0+")→Str1

]]>

Prompt A,B,D,R

ClrHome

"("->Str1

If A<0

Str1+"-"->Str1

abs(A->A

If A!=1:Then

A->N

prgmC

Str1+Str0->Str1

End

Str1+"x"->Str1

If B<0

Str1+"-"->Str1

If B>0

Str1+"+"->Str1

abs(B->B

B->N

prgmC Str1+Str0->Str1

If D<0

Str1+"-"->Str1

If D>0

Str1+"+"->Str1

abs(D->D

D->N

prgmC

Str1+Str0->Str1

If R<0

Str1+"i"->Str1

abs(R->R

Output(1,1,Str1

Output(1,length(Str1)+1,"√(

Output(1,length(Str1)+2,R

R->N

prgmNUMTOSTR

Output(1,length(Str1+Str0)+2,")

Pause

prgmC and prgmNUMTOSTR are the 2 number-to-string programs found on this site. NUMTOSTR just allows me to use the length of a number, and C actually gives me the number as a string.

]]>Turn the +- if condition and assignment to:

Str1+sub("+-",1+(B<0),1)—>Str1 ]]>

I don't know what your number-to-string code looks like, but I would move the number range testing into that program because that functionality is duplicated for both parts of the factoring program. With that change made, your main program simply becomes:

:"(→Str1

:Prompt A,B

:A:prgmC

:Str1+Str0+"x→Str1

:"+

:If B<0

:"-

:Str1+Ans→Str1

:B:prgmC

:Str1+Str0+")→Str1

Prompt A,B

"("->Str1

If A<0

Str1+"-"->Str1

abs(A->A

If A!=1

Then

A->N

prgmC

Str1+Str0->Str1

End

Str1+"x"->Str1

If B<0

Str1+"-"->Str1

If B>0

Str1+"+"->Str1

abs(B->B

B->N

prgmC

Str1+Str0+")"->Str1

Disp Str1

It works but if you can find a better way to do the same thing, do share.

]]>` ``Input N //Input is my favorite prgmC If 1!=abs(N //This will cover everything but 1 and -1 "("+Str0->Str2 If N=-1 "(‾->Str2 Disp Str2+"X)`

For 1, you will get (X)

For -1, you will get (-X)

For N, you will get (NX)

That's what you wanted, not?

]]>:"(->Str2

:Prompt N

:prgmC

:Str2+Str0->Str2

:If abs(N)=1

:sub(Str2,1,length(Str2)-1->Str2

:Str2+"x->Str2

:Disp Str2

The code you gave me works to a point, I would like if when N=-1 the output was "(-x

(prgmC just takes a real whole number and turns it into a string, Str0.

` ``length(str2)-1->length(str2)`

To shorten a string you need the sub( command, to erase the last character it would be:

` ``sub(Str2,1,length(Str2)-1->Str2`

and for erasing the first character respectively:

` ``sub(Str2,2,length(Str2->Str2`

You have to explain what your program is supposed to do in order to get accurate advices.

]]>:1->A

:str2+"x->str2

:if abs(A)=1

:length(str2)-1->length(str2)

Obviously I can't do that but I want str2 (if abs(A)=1), to be "(x+B)" instead of "(1x+B)".

Can I get some help?