Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

19
Task/Pi/Haskell/pi-1.hs Normal file
View file

@ -0,0 +1,19 @@
pi_ = g (1, 0, 1, 1, 3, 3)
where
g (q, r, t, k, n, l) =
if 4 * q + r - t < n * t
then n :
g
( 10 * q
, 10 * (r - n * t)
, t
, k
, div (10 * (3 * q + r)) t - 10 * n
, l)
else g
( q * k
, (2 * q + r) * l
, t * l
, k + 1
, div (q * (7 * k + 2) + r * l) (t * l)
, l + 2)

18
Task/Pi/Haskell/pi-2.hs Normal file
View file

@ -0,0 +1,18 @@
#!/usr/bin/runhaskell
import Control.Monad
import System.IO
pi_ = g(1,0,1,1,3,3) where
g (q,r,t,k,n,l) =
if 4*q+r-t < n*t
then n : g (10*q, 10*(r-n*t), t, k, div (10*(3*q+r)) t - 10*n, l)
else g (q*k, (2*q+r)*l, t*l, k+1, div (q*(7*k+2)+r*l) (t*l), l+2)
digs = insertPoint digs'
where insertPoint (x:xs) = x:'.':xs
digs' = map (head . show) pi_
main = do
hSetBuffering stdout $ BlockBuffering $ Just 80
forM_ digs putChar

3
Task/Pi/Haskell/pi-3.hs Normal file
View file

@ -0,0 +1,3 @@
piG3 = g(1,180,60,2) where
g(q,r,t,i) = let (u,y)=(3*(3*i+1)*(3*i+2),div(q*(27*i-12)+5*r)(5*t))
in y : g(10*q*i*(2*i-1),10*u*(q*(5*i-2)+r-y*t),t*u,i+1)