Ad
  • Custom User Avatar

    Same goes for this:

    ArrayComprehension({
        generator: '1..',
      filters[isPrime]
    }).take(10).map(addOne).filter(isPrime).value(); //[ 2, 3 ]
    

    1 is not prime, so 2 shouldn't be in the results. 3 is the only prime number whose predecessor is also prime (2); 2 is the only even prime number, so we know this has to be true. Every other prime is odd, and its predecessor is even, so its predecessor is not prime (it's divisible by 2). Also why trying to take(10) is an infinite loop.