2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
15
Task/Pi/Fortran/pi-1.f
Normal file
15
Task/Pi/Fortran/pi-1.f
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
Coded by Stanley Rabinowitz, 12 Vine Brook Road, Westford MA, 01886-4212.
|
||||
INTEGER VECT(3350),BUFFER(201)
|
||||
DATA VECT/3350*2/,MORE/0/
|
||||
DO 2 N = 1,201
|
||||
KARRAY = 0
|
||||
DO 3 L = 3350,1,-1
|
||||
NUM = 100000*VECT(L) + KARRAY*L
|
||||
KARRAY = NUM/(2*L - 1)
|
||||
3 VECT(L) = NUM - KARRAY*(2*L - 1)
|
||||
K = KARRAY/100000
|
||||
BUFFER(N) = MORE + K
|
||||
2 MORE = KARRAY - K*100000
|
||||
WRITE (*,100) BUFFER
|
||||
100 FORMAT (I2,"."/(1X,10I5.5))
|
||||
END
|
||||
48
Task/Pi/Fortran/pi-2.f
Normal file
48
Task/Pi/Fortran/pi-2.f
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
!================================================
|
||||
program pi_spigot_unbounded
|
||||
!================================================
|
||||
do
|
||||
call print_next_pi_digit()
|
||||
end do
|
||||
|
||||
contains
|
||||
|
||||
!------------------------------------------------
|
||||
subroutine print_next_pi_digit()
|
||||
!------------------------------------------------
|
||||
use fmzm
|
||||
type (im) :: q, r, t, k, n, l, nr
|
||||
logical :: dot=.false., init=.false.
|
||||
save :: q, r, t, k, n, l
|
||||
if (.not.init) then
|
||||
q=to_im(1)
|
||||
r=to_im(0)
|
||||
t=to_im(1)
|
||||
k=to_im(1)
|
||||
n=to_im(3)
|
||||
l=to_im(3)
|
||||
init=.true.
|
||||
end if
|
||||
if (4*q+r-t < n*t) then
|
||||
write(6,fmt='(i1)',advance='no') to_int(n)
|
||||
if (.not.dot) then
|
||||
write(6,fmt='(a1)',advance='no') '.'
|
||||
dot=.true.
|
||||
end if
|
||||
flush(6)
|
||||
nr = 10 * ( r - n*t )
|
||||
n = 10 * ( (3*q + r) / t - n )
|
||||
q = 10 * q
|
||||
r = nr
|
||||
else
|
||||
nr = (2*q + r) * l
|
||||
n = ( (q * (7*k + 2) + r*l) / (t*l) )
|
||||
q = q * k
|
||||
t = t * l
|
||||
l = l + 2
|
||||
k = k + 1
|
||||
r = nr
|
||||
end if
|
||||
end subroutine
|
||||
|
||||
end program
|
||||
Loading…
Add table
Add a link
Reference in a new issue