Question

So I'm writing a TI-BASIC algorithm for my calculator that does ratios. Here is the code:

Disp "GIVE ONE NUMBER"
Prompt A
Disp "GIVE A SECOND NUMBER"
Prompt B
While fPart(A)≠0 or fPart(B)≠0
A*10->A
B*10->B
End
gcd(A,B)->C
Disp A/C
Disp B/C

It seems to work in most cases. Are there any flaws/corner cases of this code that I have not noticed? Thanks.

Was it helpful?

Solution

It will work, but there is an even cooler way to do it with no loops.

Disp "GIVE ONE NUMBER"
Prompt A
Disp "GIVE A SECOND NUMBER"
Prompt B
1/fPart(A)->F
A*F->A
B*F->B
1/fPart(B)->F
A*F->A
B*F->B
gcd(A,B)->C
Disp A/C
Disp B/C

OTHER TIPS

Yes it will work and so will Jean-Bernard Pellerin's answer, but to best clean it up:

Input "GIVE ONE NUMBER",A
Input "GIVE A SECOND NUMBER",B
1/fPart(A)->F
A*F->A
B*F->B
1/fPart(B)->F
A*F->A
B*F->B
gcd(A,B)->C
Disp A/C
Disp B/C
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top