Skip to content

Instantly share code, notes, and snippets.

@gkucmierz
Created October 30, 2024 12:59
Show Gist options
  • Save gkucmierz/646ca87052a73713b9a311e5d1de9b05 to your computer and use it in GitHub Desktop.
Save gkucmierz/646ca87052a73713b9a311e5d1de9b05 to your computer and use it in GitHub Desktop.
// https://projecteuler.net/problem=57
const squareRoot = n => {
const STEPS = 100;
let res = 0;
for (let i = 0; i < STEPS; ++i) {
res = (n-1) / (2 + res);
}
return res + 1;
};
for (let i = 0; i < 20; ++i) {
console.log(i, squareRoot(i), i ** 0.5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment