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.
@FArekkusu, I know the algorithm is correct, I just wanted to show which iterations are unnecessary without giving any hints. And by explaining me the exact mechanical process the user must've a thought: why am I repeating things and doing uncessary work, which is often missed when algorithm is not thought with sufficient amount of patience.
Why exactly up to
num/2
? It's also too much. Let's take a biggenr umber, for example 101. Do you really need to check up to101 % 50
? Hint: no, you don't.The algorithm is correct. The only problem is that it does a lot more work than required, as hinted in the @hobovsky's comment.
Do you really nee to check
17 % 16?
how will you verify whether 17 is a prime number?
(tell me the exact mechanical process)