100 REM adopted from Applesoft BASIC 110 n = 100 : rem n may be increased, but will slow execution 120 ln = int(10*n/3)+16 130 nd = 1 140 dim a(ln) 150 n9 = 0 160 pd = 0 : rem First pre-digit is a 0 170 rem 180 for j = 1 to ln 190 a(j-1) = 2 : rem Start wirh 2S 200 next j 210 rem 220 for j = 1 to n 230 q = 0 240 for i = ln to 1 step -1 : rem Work backwards 250 x = 10*a(i-1)+q*i 260 a(i-1) = x-(2*i-1)*int(x/(2*i-1)) : rem X - Int ( X / Y) * Y 270 q = int(x/(2*i-1)) 280 next i 290 a(0) = q-10*int(q/10) 300 q = int(q/10) 310 if q = 9 then n9 = n9+1 : goto 510 320 if q <> 10 then goto 440 330 rem Q == 10 340 d = pd+1 : gosub 560 350 if n9 <= 0 then goto 400 360 for k = 1 to n9 370 d = 0 : gosub 560 380 next k 390 rem End If 400 pd = 0 410 n9 = 0 420 goto 510 430 rem Q <> 10 440 d = pd : gosub 560 450 pd = q 460 if n9 = 0 then goto 510 470 for k = 1 to n9 480 d = 9 : gosub 560 490 next k 500 n9 = 0 510 next j 520 print str$(pd) 530 end 540 rem 550 rem Output digits 560 if nd = 0 then print str$(d); : return 570 if d = 0 then return 580 print str$(d);"."; 590 nd = 0 600 return