 late againJune 27 2011 at 10:15 AM  David (no login) 
Response to Pi as a fraction 

This uses the method of "continued fractions". I suspect qbguy's program dose as well, but his is more elegant. Change DP to get more (or less) decimal places.
DEFDBL AB, X
DIM N(25) AS INTEGER
DP = 10
X = 4# * ATN(1#)
N(0) = INT(X)
A = X  N(0)
X2 = A
X9 = 5# / (10 ^ DP)
X8 = INT(X * 10 ^ (DP  1) + .5) / (10 ^ (DP  1))
WHILE ABS(X1  X2) > X9
J = J + 1
b = 1 / A
N(J) = INT(b)
A = (b  N(J))
L = 0: K = 0
L = N(J) * N(J  1) + 1
K = N(J)
FOR m = J  2 TO 1 STEP 1
kk = L
L = L * N(m) + K
K = kk
NEXT m
X1 = CDBL(K) / CDBL(L)
WEND
PRINT X8; " = "; L * N(0) + K; "/"; L  
 Responses 

