Please paste your errors as comments into this gist. Paste both your code and the error message.
Created
December 22, 2016 18:53
-
-
Save airportyh/05452978247e322d8df6fc232d90a228 to your computer and use it in GitHub Desktop.
Author
person.friends[0].name.length
// __ __
// | \\\ /__\
// |.\\\ \ //--.i
// i \\\\ \ ///// i
// i \\\\\ \ _______ //////:|
// i.\\\\\\ --|i | i|-- /////.|
// |:\\\\ |||:i i iiii| /// i
// \ \ / i|i | |||i\ i
// / :| || i i| i i
// | |: i | | |i| \
// i | || | i i| i
// | / | : | \\ i
// | // __ :.:: __ \ i
// | / _\ / _\ i
// | | # \ # \ i
// i ___--| \_) \_)--___ |
// i==== \__/ \__/ ====|
// i== ==|
// i- _-_ -i
// /| \ / i
// // \ _ _ --- | -- _ /
// / _\- - _-- | --_ --_ /
// / - \_ _- _- | -- -_ /_
// / _ -\_ -- -__/ \__- -_ _/_ -
// // - _---__ \___/ --__/_ -
// _- -_
console.time('countPrimes');
countPrimes(2000000);
console.timeEnd('countPrimes');
function countPrimes(num) {
var knownPrimes = [2,3,5];
var sum = 0;
for (var i = 6; i < num; i++) {
if((i % 2 != 0) && (i % 3 != 0) && (i % 5 != 0)) {
for (var j = 0; j < knownPrimes.length; j++) {
if (i % knownPrimes[j] == 0) {
beak;
}
if ((j == (knownPrimes.length - 1) ) && (i % knownPrimes[j] != 0)) {
knownPrimes.push(i);
}
}
}
}
sum = knownPrimes.reduce(function(a,b){
return a + b;
},0);
console.log(sum);
}
X - Uncaught SyntaxError: Unexpected identifier script.js:2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uncaught TypeError: i is not a function(…)