Hello everyone. I see you're having quite a fight about the little number pi. So I thought, I'll join.

But no, seriously, I've got quite interested. The idea of making a pi-generator in a 20-liner is refreshingly alternative, but also very dull. Nevertheless, the way the mathematicians interpolated pi was by this row:

PI = 4(1/1-1/3+1/5-1/7+1/9-1/11+1/13-...)

Atleast one can comprehend or derive most of the important irrational numbers in some sort of interpolable formula, else it'll have been as if maths crashed into an invisible wall an' got knocked-out for ever

.

The problem with my program is the same with those above — I can only press out 5 dp accurately, after that, there's just casual junk of numbers.

Btw, did you know, that pi also plays a protruding role in nature's ways? The way a river runs has a length ratio to the direct airline is

*pi to 1*. I think that's incredible on my behalf. — At least it's worth commenting.

There yer go with my piece of sub-20-line-coding:

start:
posneg#=-1 : t#=-1 : piquarter as double float : piquarter = 0 : set text font "Courier New" : set text size 14 : ink rgb(0,255,0),1 : input "Calculate PI to ... decimal places (dp) > ",dp
for s=1 to dp^4 : posneg#=posneg#*-1 : t#=t#+2 : piquarter = piquarter+10^dp/t#*posneg# : if s=2000000 : print "Have patience. Interpolating..." : sync : endif : if escapekey() : exit : endif next s
if dp>=100 : print "Demanded dp exceeds range of program interpolation." : endif : pi as double float : pi = 4*val(str$(piquarter/10^dp,dp)) : print "PI = ",pi
if s<>1 : print str$(s)+" Interpolation cycles." : else : print str$(s)+" Interpolation cycle." : endif : print "Press <SPACE> to copy PI to clipboard." : print "Press <SHIFT> to save PI to 'pi.txt'." : print "Press <ENTER> to recalculate PI." : print "Press <ESC> to exit."
do : if returnkey()=0 : exit : endif : loop
do : if spacekey() : write to clipboard str$(pi) : endif : if shiftkey() : if file exist("pi.txt") : delete file "pi.txt" : endif : open to write 1,"pi.txt" : write string 1,str$(pi) : close file 1 : endif : if returnkey() : goto start : exit : endif : loop

Wherever you plan to go,

it's the next step you never know.