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.
i does not need to iterate over all the whole numbers. 2 is the only even whole number that can be a prime. It's nearly twice as fast to first check if the input is divisible by 2 and is not 2, and then starting i off at 3 and iterating with i += 2.
Also, the loop does not need to go until num/2. Once you get past the square root, there's no point in checking any longer, it has to be prime.
Example runtimes with a large odd number input:
iterating over all integers up to num/2: 0.007080078125ms
interating over odd numbers up to Math.sqrt(num): 0.002685546875ms
I just saw that, do you mean it does not pass this example test from the description because I added it Test.assertEquals(findEvenIndex([20,10,-80,10,10,15,35]),0, "The array was: [20,10,-80,10,10,15,35] \n");
and that test fails with this solution?
ah just saw other people said the same.
This doesn't work!!!!