{"size": 363, "ext": "js", "max_stars_repo_path": "Sqrt/index.js", "max_stars_repo_name": "Berkmann18/LeetCode", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Sqrt/index.js", "max_issues_repo_name": "Berkmann18/LeetCode", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sqrt/index.js", "max_forks_repo_name": "Berkmann18/LeetCode", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.1052631579, "max_line_length": 77, "alphanum_fraction": 0.3884297521}
/**
 * @param {number} x
 * @return {number}
 */
const mySqrt = (x) => {
  if (x === 1) return 1;
  let r = x / 2,
    m = -1;

  for(let i = 0; i < 20 && m !== 0; ++i) {
    let p = r**2;
    m = (x - p) / ((r + 1)**2 - p);
    // process.stdout.write('\tp=' + p + '\nm=' + m + '\n\t\tr=' + r + '\n');
    r += m;
  }
  return r | 0;
};

module.exports = mySqrt;