Skip to content

Instantly share code, notes, and snippets.

@gdejohn
Last active August 29, 2015 14:15
Show Gist options
  • Save gdejohn/67714d35eb108b6cdcaf to your computer and use it in GitHub Desktop.
Save gdejohn/67714d35eb108b6cdcaf to your computer and use it in GitHub Desktop.
Monte Carlo approximation of π
Float montePi(Integer samples) => 4.0 * count({random() ^ 2 + random() ^ 2 <= 1.0}.repeat(samples)) / samples;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment