Last active
May 11, 2016 17:17
-
-
Save snarisi/423ace9efdca1ce988cb007f57b72a6f 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
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