Jump to content

Pi: Difference between revisions

No change in size ,  2 years ago
(→‎{{header|F_Sharp|F#}}: Haskell can probably do this as an unfold, it has not so I shall in F#)
Line 2,165:
<lang fsharp>
// Generate Pi as above using unfold. Nigel Galloway: March 15th., 2022
let Piπ()=Seq.unfold(fun(q,r,t,k,n,l)->Some(if 4I*q+r-t < n*t then(Some(int n),((10I*q),(10I*(r-n*t)),t,k,((10I*(3I*q+r))/t-10I*n),l)) else (None,((q*k),((2I*q+r)*l),(t*l),(k+1I),((q*(7I*k+2I)+r*l)/(t*l)),(l+2I)))))(1I,0I,1I,1I,3I,3I)|>Seq.choose id
Piπ()|>Seq.take 767|>Seq.iter(printf "%d")
</lang>
 
2,172

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.