Skip to content

Instantly share code, notes, and snippets.

@olooney
Last active February 12, 2019 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olooney/592997c07534e6e3bd2029013a0dc3eb to your computer and use it in GitHub Desktop.
Save olooney/592997c07534e6e3bd2029013a0dc3eb to your computer and use it in GitHub Desktop.
# https://www.youtube.com/watch?v=d3mHfqd0VZY
def harmonic(x, y, n=6, epsilon=1e-3):
r = sqrt(x/y)
for a in range(1, n):
for b in range(1, n):
if abs(r - a/b) < epsilon:
return True
return False
for x in np.arange(1.6, 6.4, 0.2):
for y in np.arange(1.6, 6.4, 0.2):
status = '✔️' if harmonic(x, y) else '❌'
#print("{:.2f}{}".format(sqrt(x)/sqrt(y), status), end=' ')
print("{}".format(status), end=' ')
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment