Beta

Prime Number Generator :Intermediate (with inputs) version

Description:

Using ES2015 Generators
Write a prime number generator.

Just Like in the kata Prime Number Generator:Simple version

It should return each prime number in order.
It should start with 2 as the first prime number.
Without timing out it should return up the 10,003rd prime.

Unlike the simple version it should also accept input to the next function so that

primeGen.next(N).value //returns the Nth prime

After that it should return consecutive primes starting at N+1.

primeGen.next(1).value;   // returns 2, the 1st prime
primeGen.next().value;    // returns 3, the 2nd prime
primeGen.next(100).value; // returns 541, the 100th prime
primeGen.next().value;    // returns ???, the 101st prime

if N is not a positive integer than it should behave as if it was called without an argument.

Algorithms

More By Author:

Check out these other kata created by DeanBrown

Stats:

CreatedJul 31, 2015
PublishedJul 31, 2015
Warriors Trained211
Total Skips12
Total Code Submissions325
Total Times Completed34
JavaScript Completions34
Total Stars3
% of votes with a positive feedback rating93% of 21
Total "Very Satisfied" Votes19
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments17
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • DeanBrown Avatar
Ad