Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
That's in the kata's description, so (1, 1, 10) is not a valid input
if you want to get prime numbers with 1 gap between 1 and 10 ( "gap(1, 1, 10)" ) it should return [2,3] but it will return [1,2] and 1 is not a prime number. So you should add another verification in the isPrime function whereas if i == 1 return false
Spoiler flag, please.
This comment is hidden because it contains spoiler information about the solution
Nice.
We can change
j < i
to
Math.sqrt(i) + 1
in isPrime method.
This is indeed correct, thanks for noticing! I've amended my code to recognise 1 as not prime and include 4 in the prime checks. This is submitted as a new solution here:
https://www.codewars.com/kata/reviews/561eaaf5353ce442ad00004d/groups/5b43601cff888b9e620030d6
Unfortunately, I don't know how to change this particular code here...
The isPrime method recogniyes 1 and 4 as prime numbers.
last = i;Very clever