Ad
  • Custom User Avatar

    @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.

  • Custom User Avatar

    It is enough to check up to num / 2

    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 to 101 % 50? Hint: no, you don't.

  • Custom User Avatar

    how will you verify whether 17 is a prime number?

    The algorithm is correct. The only problem is that it does a lot more work than required, as hinted in the @hobovsky's comment.

  • Custom User Avatar

    Do you really nee to check 17 % 16?

  • Custom User Avatar

    how will you verify whether 17 is a prime number?
    (tell me the exact mechanical process)