Skip to content

Instantly share code, notes, and snippets.

@alun
Created August 14, 2022 16:06
Show Gist options
  • Save alun/ad191b4a1d094d652d125efea65450b5 to your computer and use it in GitHub Desktop.
Save alun/ad191b4a1d094d652d125efea65450b5 to your computer and use it in GitHub Desktop.
import random
total=1000000
in_circle=0
for i in range(total):
(x,y)= (random.random(), random.random())
if x**2 + y**2 <= 1:
in_circle+=1
4*(in_circle/total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment