Japt: Playing with primes
Unlike some golfing languages, Japt doesn’t have too many tools to play around with prime numbers. The below patterns come up fairly frequently and may be of help.
Get the first
A prime numbers:
Èj}jA jA // Get the first A positive integers that return true È } // when run through a function that j // checks whether the number is prime.
Similarly, get the
A-th prime number:
Èj}iA iA // Get the A-th positive integer Èj} // that is prime.
Get all prime number up to
Aò fj Aò // Generate the range [0..A], fj // then only keep the ones that are prime.