loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.05572307787279418","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"Ly8gR2VuZXJhdG9yIHRvIGNhbGN1bGF0ZSBwcmltZSBudW1iZXJzCmZ1bmN0aW9uKiBwcmltZU51bWJlcnMoKSB7IAogIGxldCBuID0gMjsKCiAgd2hpbGUgKHRydWUpIHsKICAgIGlmIChpc1ByaW1lKG4pKSB5aWVsZCBuOwogICAgbisrOwogIH0KCiAgZnVuY3Rpb24gaXNQcmltZShudW0pIHsKICAgIGZvciAobGV0IGkgPSAyOyBpIDw9IE1hdGguc3FydChudW0pOyBpKyspIHsKICAgICAgaWYgKG51bSAlIGkgPT09IDApIHsKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0cnVlOwogIH0KfQoKLy8gQ3JlYXRlIGdlbmVyYXRvcgpsZXQgcHJpbWVHZW5lcmF0b3IgPSBwcmltZU51bWJlcnMoKTsKLy8gQWR2YW5jZSB0aHJvdWdoIGdlbmVyYXRvciB3aXRoIG5leHQoKSwgcHJpbnQgb3V0IHZhbHVlCmNvbnNvbGUubG9nKHByaW1lR2VuZXJhdG9yLm5leHQoKS52YWx1ZSk7CmNvbnNvbGUubG9nKHByaW1lR2VuZXJhdG9yLm5leHQoKS52YWx1ZSk7CmNvbnNvbGUubG9nKHByaW1lR2VuZXJhdG9yLm5leHQoKS52YWx1ZSk7CmNvbnNvbGUubG9nKHByaW1lR2VuZXJhdG9yLm5leHQoKS52YWx1ZSk7CmNvbnNvbGUubG9nKHByaW1lR2VuZXJhdG9yLm5leHQoKS52YWx1ZSk7Ci8vIENhbGxzIHRvIHByaW1lckdlbmVyYXRvci5uZXh0KCkgcmV0dXJucyBpbmZpbml0ZSBwcmltZSBudW1iZXJz"},"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
26
27
28
// Generator to calculate prime numbers
function* primeNumbers() { 
  let n = 2;

  while (true) {
    if (isPrime(n)) yield n;
    n++;
  }

  function isPrime(num) {
    for (let i = 2; i <= Math.sqrt(num); i++) {
      if (num % i === 0) {
        return false;
      }
    }
    return true;
  }
}

// Create generator
let primeGenerator = primeNumbers();
// Advance through generator with next(), print out value
console.log(primeGenerator.next().value);
console.log(primeGenerator.next().value);
console.log(primeGenerator.next().value);
console.log(primeGenerator.next().value);
console.log(primeGenerator.next().value);
// Calls to primerGenerator.next() returns infinite prime numbers
Native Browser JavaScript