TI-89 factor() return value to two variables

730 Views Asked by At

I am writing a function for my TI-89 Titanium. I see that there is a built-in factor() function under Algebra(F2). I know that in my use case it is going to be the sum of two integers; for example my function might call factor(899) in part of it and expect 29*31. How can I assign these values to two variables? I am going to need to use them later in my program. For example I might want to have q set to 29 and r set to 31.

1

There are 1 best solutions below

2
On BEST ANSWER

There's probably a better way, but I've got around this problem using the string() function.

string(factor(899))="29*31"

Then you can extract the numbers into a list from there.

EDIT:To extract just two variables, like in your example isn't too difficult.
If you are in a program, you could first store string(factor(899)) to a variable. Say string(factor(899))STO>"stringf"

Then: expr(left(stringf,inString(stringf,"*")-1)) will return 29. inString() finds the "*" in your string, left() takes the left part of your sting until right before the "*" and expr() converts the string to a number.

Similarly to get the right side of the "*" you could go with expr(right(stringf,length(stringf)-inString(stringf,"*")))