Created
August 7, 2018 12:07
-
-
Save kupp1/1b4c00776427faa3e4c9c696ee642b90 to your computer and use it in GitHub Desktop.
Gauss circle problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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