Happy Pi Day!
For those who put the month before the day (why?), today is 3/14: Pi day.
So happy Pi day! Have some pi:
let p d = take d(fix(\i y h->let(z,x)=fix(\f xs->case xs of{((n,d,c):y)->let{(z,k)=f
y;(q,r)=(c*10+k)`divMod`d}in((n,d,r):z,n*q);_->([],0)})y in case x of{9->i z(h++[9])
10->i z(map(\x->(x+1)`mod`10)h++[0]);_->h++i z[x]})((1,10,2):[(i,2*i+1,2)
|i<-[1..(10*d)`div`3]])[])in p 100
Feel free to change the "100" at the end to however much precision you need.
Categories
haskell , mathematics0 TrackBacks
Listed below are links to blogs that reference this entry: Happy Pi Day!.
TrackBack URL for this entry: http://andrew.bromage.org/mt/mt-tb.cgi/97

Leave a comment