Skip to content

Instantly share code, notes, and snippets.

@smunkel
Created July 21, 2020 00:51
Show Gist options
  • Save smunkel/a65e6d9fd181f0b935df900fd6a43294 to your computer and use it in GitHub Desktop.
Save smunkel/a65e6d9fd181f0b935df900fd6a43294 to your computer and use it in GitHub Desktop.
from math import gcd, sqrt
import random
def area(radius):
c = 0
for total in range(4_631_219):
a = random.randint(1, 666)
b = random.randint(1, 666)
if gcd(a, b) == 1:
c += 1
return sqrt(6 * total / c * (radius ** 4))
if __name__ == "__main__":
while True:
radius = input("circle's radius: ")
try:
radius = float(radius)
break
except ValueError:
continue
print(area(radius))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment