An emirp (prime spelled backwards) are primes that when reversed (in their decimal representation) are a different prime.
Write a function that should be able to : Show the first n eprimes numbers.Show the eprimes numbers in a range.Show the number of eprimes in a range.Show the nth eprimes number.
The function should have two parameters. The first will receive n or the range as an array. The second will receive a boolean, that specifies if the function returns the eprimes as an array or a single number(the number of primes in the range or the nth prime). According to the parameters the function should return an array or a number.
emirps
is a function.
testString: assert(typeof emirps === 'function', 'emirps
is a function.');
- text: emirps(20,true)
should return [13,17,31,37,71,73,79,97,107,113,149,157,167,179,199,311,337,347,359,389]
testString: assert.deepEqual(emirps(20, true), [13, 17, 31, 37, 71, 73, 79, 97, 107, 113, 149, 157, 167, 179, 199, 311, 337, 347, 359, 389], 'emirps(20,true)
should return [13,17,31,37,71,73,79,97,107,113,149,157,167,179,199,311,337,347,359,389]
');
- text: emirps(10000)
should return 948349
testString: assert.deepEqual(emirps(10000), 948349, 'emirps(10000)
should return 948349
');
- text: emirps([7700,8000],true)
should return [7717,7757,7817,7841,7867,7879,7901,7927,7949,7951,7963]
testString: assert.deepEqual(emirps([7700, 8000], true), [7717, 7757, 7817, 7841, 7867, 7879, 7901, 7927, 7949, 7951, 7963], 'emirps([7700,8000],true)
should return [7717,7757,7817,7841,7867,7879,7901,7927,7949,7951,7963]
');
- text: emirps([7700,8000],true)
should return 11
testString: assert.deepEqual(emirps([7700, 8000], false), 11, 'emirps([7700,8000],true)
should return 11
');
```