### TI-89 Long Division Program

Today I had to find the first 50 digits of 1/95. With all our modern technology, it should be easy to find, right? Unfortunately, the Windows calculator cuts off at 36 digits, and my sophisticated TI-89 cuts off all operations after a measly 16 digits.

The solution? I wrote me own long division program:

div(n,x,t)

Prgm

""->res

10->n

0->d

0->s

While t>d

iPart(n/x)->q

n-x*q->r

res&string(q)->res

r->n

if s=0 and x>n then

res&"."->res

1->s

EndIf

d+1->d

10*n->n

EndWhile

EndPrgm

This program accepts three parameters: n, x, and t. It divides n by x and outputs the first t digits into the variable res (for result :P).

## 4 comments:

This seems to be helpful to me as well except I have run into some errors. Can you double check the code b/c i just tried out the program and it returned that there were too few arguments, im a noob to this style of programming so i cant fix it myself. :/

There doesn't seem to be anything wrong with the program.

Did you enter all three arguments?

There is two "EndWhile" statements and only one "While" statement but I'm a noob at programming here...

Oh thanks Anonymous, closer inspection revealed that there were several errors in what i put online, which I blame on hasty typing. Sorry for the confusion, it should work now!

Post a Comment