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.
Mann, spent much time writing it in C++ then realized C++ is not supported :(
This comment is hidden because it contains spoiler information about the solution
yep you are right, I just added the floor for understanding, didn't mean it to be added in actual code.
is it really important to add floor()? as i is an integer, would it not just run the same amount of loops?
this code doesn't account for primary numbers, can be quickly corrected by checking for ns smaller than 0 and returning false as no negative numbers are prime, a.s - given an integer -n for n as any positive integer -n is always divisible by n which is a divisor other than one and itself
Run the loop only till i < n/2 instead of n (strictly speaking should be only till square root of n but this works too) . That way, in case the number is prime, your loop will only run half as many times (again, this could be improved further by running it floor(sqrt(n)) many times). Just making it more efficient.