B
This commit is contained in:
parent
e5e8880e41
commit
518da4a923
1019 changed files with 15877 additions and 0 deletions
59
Task/Pi/BASIC256/pi.basic256
Normal file
59
Task/Pi/BASIC256/pi.basic256
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
|
||||
23
Task/Pi/BBC-BASIC/pi-1.bbc
Normal file
23
Task/Pi/BBC-BASIC/pi-1.bbc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
WIDTH 80
|
||||
M% = (HIMEM-END-1000) / 4
|
||||
DIM B%(M%)
|
||||
FOR I% = 0 TO M% : B%(I%) = 20 : NEXT
|
||||
E% = 0
|
||||
L% = 2
|
||||
FOR C% = M% TO 14 STEP -7
|
||||
D% = 0
|
||||
A% = C%*2-1
|
||||
FOR P% = C% TO 1 STEP -1
|
||||
D% = D%*P% + B%(P%)*&64
|
||||
B%(P%) = D% MOD A%
|
||||
D% DIV= A%
|
||||
A% -= 2
|
||||
NEXT
|
||||
CASE TRUE OF
|
||||
WHEN D% = 99: E% = E% * 100 + D% : L% += 2
|
||||
WHEN C% = M%: PRINT ;(D% DIV 100) / 10; : E% = D% MOD 100
|
||||
OTHERWISE:
|
||||
PRINT RIGHT$(STRING$(L%,"0") + STR$(E% + D% DIV 100),L%);
|
||||
E% = D% MOD 100 : L% = 2
|
||||
ENDCASE
|
||||
NEXT
|
||||
23
Task/Pi/BBC-BASIC/pi-2.bbc
Normal file
23
Task/Pi/BBC-BASIC/pi-2.bbc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
DIM P% 32
|
||||
[OPT 2 :.pidig mov ebp,eax :.pi1 imul edx,ecx : mov eax,[ebx+ecx*4]
|
||||
imul eax,100 : add eax,edx : cdq : div ebp : mov [ebx+ecx*4],edx
|
||||
mov edx,eax : sub ebp,2 : loop pi1 : mov eax,edx : ret :]
|
||||
|
||||
WIDTH 80
|
||||
M% = (HIMEM-END-1000) / 4
|
||||
DIM B%(M%) : B% = ^B%(0)
|
||||
FOR I% = 0 TO M% : B%(I%) = 20 : NEXT
|
||||
E% = 0
|
||||
L% = 2
|
||||
FOR C% = M% TO 14 STEP -7
|
||||
D% = 0
|
||||
A% = C%*2-1
|
||||
D% = USR(pidig)
|
||||
CASE TRUE OF
|
||||
WHEN D% = 99: E% = E% * 100 + D% : L% += 2
|
||||
WHEN C% = M%: PRINT ;(D% DIV 100) / 10; : E% = D% MOD 100
|
||||
OTHERWISE:
|
||||
PRINT RIGHT$(STRING$(L%,"0") + STR$(E% + D% DIV 100),L%);
|
||||
E% = D% MOD 100 : L% = 2
|
||||
ENDCASE
|
||||
NEXT
|
||||
29
Task/Pi/Bracmat/pi.bracmat
Normal file
29
Task/Pi/Bracmat/pi.bracmat
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
( pi
|
||||
= f,q r t k n l,first
|
||||
. !arg:((=?f),?q,?r,?t,?k,?n,?l)
|
||||
& yes:?first
|
||||
& whl
|
||||
' ( 4*!q+!r+-1*!t+-1*!n*!t:<0
|
||||
& f$!n
|
||||
& ( !first:yes
|
||||
& f$"."
|
||||
& no:?first
|
||||
|
|
||||
)
|
||||
& "compute and update variables for next cycle"
|
||||
& 10*(!r+-1*!n*!t):?nr
|
||||
& div$(10*(3*!q+!r).!t)+-10*!n:?n
|
||||
& !q*10:?q
|
||||
& !nr:?r
|
||||
| "compute and update variables for next cycle"
|
||||
& (2*!q+!r)*!l:?nr
|
||||
& div$(!q*(7*!k+2)+!r*!l.!t*!l):?nn
|
||||
& !q*!k:?q
|
||||
& !t*!l:?t
|
||||
& !l+2:?l
|
||||
& !k+1:?k
|
||||
& !nn:?n
|
||||
& !nr:?r
|
||||
)
|
||||
)
|
||||
& pi$((=.put$!arg),1,0,1,1,3,3)
|
||||
Loading…
Add table
Add a link
Reference in a new issue