Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
62
Task/Pi/Yabasic/pi.basic
Normal file
62
Task/Pi/Yabasic/pi.basic
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
n = 1000
|
||||
long = 10 * int(n / 4)
|
||||
needdecimal = 1 //true
|
||||
dim a(long)
|
||||
nines = 0
|
||||
predigit = 0 // {First predigit is a 0}
|
||||
|
||||
for j = 1 to long
|
||||
a(j-1) = 2 // {Start with 2s}
|
||||
next j
|
||||
|
||||
for j = 1 to n
|
||||
q = 0
|
||||
for i = long to 1 step -1
|
||||
// {Work backwards}
|
||||
x = 10*a(i-1) + q*i
|
||||
a(i-1) = mod(x, (2*i - 1))
|
||||
q = int(x / (2*i - 1))
|
||||
next i
|
||||
a(0) = mod(q, 10)
|
||||
q = int(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
|
||||
|
||||
label outputd
|
||||
if needdecimal then
|
||||
if d = 0 then return : fi
|
||||
print d;
|
||||
print ".";
|
||||
needdecimal = 0 //false
|
||||
else
|
||||
print "", d;
|
||||
endif
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue