Skip to content

Instantly share code, notes, and snippets.

@auselen auselen/π.md
Last active Mar 24, 2017

Embed
What would you like to do?

Code

 awk 'BEGIN{srand(); while (++i) {pi += ((rand()**2+rand()**2) <= 1); if ((i%10e5) == 0) printf "%f\n",4*pi/i;}}'

Result

3.140352
3.139892
3.140535
3.140230
3.140933
3.141291
3.140802
3.140831
3.140884
3.141042
3.141076
3.141043
3.141200
3.141418
3.141367
3.141500
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.