I was wondering if it is possible to create a program that can solve these puzzles:

There are two numbers you need to find, and if you multiply them, the result will be the top number.
Their sum will be the bottom number. Right and left are the answers. Is it possible to find those answers with TI-BASIC?
If you solve for one of the numbers, you get A=(sum+sqrt(sum^2-4*product))/2 and B=sum-A=(sum-sqrt(sum^2-4*product))/2.

Code:
Input "Sum: ", S
Input "Product: ", P
Disp "Answers:"
Disp (S+sqrt(S^^2-4*P))/2
Disp (S-sqrt(S^^2-4*P))/2
It's really simple honestly. All that's needed is one answer value which we can obtain just by going through the possible values incrementally.

Code:
Prompt A,B
~B-1->X                    //Lower Bounds of the possible answers since neither answer can be larger than B
Repeat Ans=A
X+1->X                //Incrementing for each loop
(B-X)X
End
Disp "Answers:",X,A/X

I figured out the answers are actually just the x-intercepts of a quadratic parabola, so it's really just finding those. There is probably a better or faster way of doing this but I'm too lazy to look.

Edit: I forgot to mention that A is the product and B is the sum.

Edit x2: So I just realized that clevor already gave a better response... Still good to have multiple methods though.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement