Created
December 24, 2018 20:48
-
-
Save tatarize/430cca6708a512f17cf0a8d674ca3d41 to your computer and use it in GitHub Desktop.
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
import math | |
value = math.pi * 2 | |
best = 1e-5 | |
for i in range(1, 1000000): | |
fraction = float(i) / 12 | |
numer = round(value * fraction) | |
v = numer / float(fraction) | |
err = v - value | |
if abs(err) < best: | |
print(str(numer) + "/" + str(float(i)) + "=" + str(v) + " @ " + str(err)) | |
best = abs(err) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment