Skip to content

Instantly share code, notes, and snippets.

@snarisi
Last active May 11, 2016 17:17
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 snarisi/423ace9efdca1ce988cb007f57b72a6f to your computer and use it in GitHub Desktop.
Save snarisi/423ace9efdca1ce988cb007f57b72a6f to your computer and use it in GitHub Desktop.
function count_Squares(arr) {
/*
don't need the memo...
the floor of the square root of the number is the number of squares up to that point
*/
for (let i = 0; i < arr.length; i++) {
let curr = arr[i].split(' ').map(str => parseInt(str, 10));
let a = curr[0];
let b = curr[1];
let x = Math.floor(Math.sqrt(a));
let y = Math.floor(Math.sqrt(b));
console.log(y - x);
}
}
count_Squares(["3 9", "17 24"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment