YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
59
Task/Pi/BASIC/pi-1.basic
Normal file
59
Task/Pi/BASIC/pi-1.basic
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
cls
|
||||
|
||||
n =1000
|
||||
len = 10*n \ 4
|
||||
needdecimal = true
|
||||
dim a(len)
|
||||
nines = 0
|
||||
predigit = 0 # {First predigit is a 0}
|
||||
|
||||
for j = 1 to len
|
||||
a[j-1] = 2 # {Start with 2s}
|
||||
next j
|
||||
|
||||
for j = 1 to n
|
||||
q = 0
|
||||
for i = len to 1 step -1
|
||||
# {Work backwards}
|
||||
x = 10*a[i-1] + q*i
|
||||
a[i-1] = x % (2*i - 1)
|
||||
q = x \ (2*i - 1)
|
||||
next i
|
||||
a[0] = q % 10
|
||||
q = q \ 10
|
||||
if q = 9 then
|
||||
nines = nines + 1
|
||||
else
|
||||
if q = 10 then
|
||||
d = predigit+1: gosub outputd
|
||||
if nines > 0 then
|
||||
for k = 1 to nines
|
||||
d = 0: gosub outputd
|
||||
next k
|
||||
end if
|
||||
predigit = 0
|
||||
nines = 0
|
||||
else
|
||||
d = predigit: gosub outputd
|
||||
predigit = q
|
||||
if nines <> 0 then
|
||||
for k = 1 to nines
|
||||
d = 9: gosub outputd
|
||||
next k
|
||||
nines = 0
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
next j
|
||||
print predigit
|
||||
end
|
||||
|
||||
outputd:
|
||||
if needdecimal then
|
||||
if d = 0 then return
|
||||
print d + ".";
|
||||
needdecimal = false
|
||||
else
|
||||
print d;
|
||||
end if
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue