Skip to content

Instantly share code, notes, and snippets.

@auselen
Last active March 24, 2017 15:23
Show Gist options
  • Save auselen/0f6f467da91d0003eb345b80af0f27e8 to your computer and use it in GitHub Desktop.
Save auselen/0f6f467da91d0003eb345b80af0f27e8 to your computer and use it in GitHub Desktop.

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