Created
December 9, 2015 04:29
-
-
Save shinhirota/99a0fbd0616b15c3d4c2 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
#!/usr/local/bin/node | |
var minErr = 4; | |
for (var i = 1; i < 100000000; i++) { | |
var j = Math.floor(Math.PI * i); | |
var err = Math.abs(Math.PI - (j/i)); | |
var err1 = Math.abs(Math.PI - ((j+1)/i)); | |
if (err > err1) { | |
err = err1; | |
j = j+1; | |
} | |
if (minErr > err) { | |
minErr = err; | |
console.log("" + j + "/" + i + " = " + (j / i) + ", ERR=" + err); | |
if (err == 0) break; | |
} | |
} | |
console.log("DONE with i=" + i); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment