Skip to content

Instantly share code, notes, and snippets.

@kupp1
Created August 7, 2018 12:07
Show Gist options
  • Save kupp1/1b4c00776427faa3e4c9c696ee642b90 to your computer and use it in GitHub Desktop.
Save kupp1/1b4c00776427faa3e4c9c696ee642b90 to your computer and use it in GitHub Desktop.
Gauss circle problem
# brute-force solution 1
radius = float(input('Enter radius: '))
square_radius = radius * radius
int_count = 0
max_int = int(radius)
min_int = (-1) * max_int
for i in range(min_int, max_int + 1):
for j in range(min_int, max_int + 1):
if (i*i) + (j*j) <= square_radius:
int_count += 1
print('Integers count:', int_count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment