loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.04755247601162638","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"ZnVuY3Rpb24gaXNQcmltZShudW0xKXsKCXZhciByZW1haW5kZXIgPSBbXTsKCXZhciBzcXVhcmVyb290ID0gTWF0aC5mbG9vcihNYXRoLnNxcnQobnVtMSkpCglmb3IobGV0IGk9MjtpPHNxdWFyZXJvb3Q7aSsrKXsKCQlyZW1haW5kZXIucHVzaChudW0xJWkpOwoJICBjb25zb2xlLmxvZygicHVzaCB0byByZW1haW5kZXJzIGFycmF5OiAiKyhudW0xJWkpKTsKfQogIAlpZihyZW1haW5kZXIuaW5jbHVkZXMoMCkpewoJCXJldHVybiBmYWxzZTsKCX0KCXJldHVybiB0cnVlOwoJfQpmdW5jdGlvbiBzdW1QcmltZXMobnVtKSB7CiAgdmFyIG5ld0FyciA9W10KICBmb3IobGV0IGo9MTtqPG51bTtqKyspewogICAgaWYoaXNQcmltZShqKSl7CiAgICAgIGNvbnNvbGUubG9nKGorIiBpcyBhIHByaW1lIik7CiAgICAgIG5ld0Fyci5wdXNoKGopOwogICAgfQogIH0KCiAgcmV0dXJuIG5ld0Fyci5yZWR1Y2UoKChhLGIpID0+IGErYiksMCk7Cn0KCnN1bVByaW1lcygxMCk7"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function isPrime(num1){
	var remainder = [];
	var squareroot = Math.floor(Math.sqrt(num1))
	for(let i=2;i<squareroot;i++){
		remainder.push(num1%i);
	  console.log("push to remainders array: "+(num1%i));
}
  	if(remainder.includes(0)){
		return false;
	}
	return true;
	}
function sumPrimes(num) {
  var newArr =[]
  for(let j=1;j<num;j++){
    if(isPrime(j)){
      console.log(j+" is a prime");
      newArr.push(j);
    }
  }

  return newArr.reduce(((a,b) => a+b),0);
}

sumPrimes(10);
node v10.16.0