Skip to content

Instantly share code, notes, and snippets.

@Elijah-Bodden
Last active December 21, 2022 20:26
Show Gist options
  • Save Elijah-Bodden/8edba9acd0ed921d495c7afecb032f97 to your computer and use it in GitHub Desktop.
Save Elijah-Bodden/8edba9acd0ed921d495c7afecb032f97 to your computer and use it in GitHub Desktop.
import random
def PI(precision):
j = 0
for i in range(precision):
x = random.random()
y = random.random()
if (x ** 2 + y ** 2 < 1): j += 1
return j/precision * 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment