Ad
  • Custom User Avatar

    It's fast enough, but it's not as fast.

  • Custom User Avatar

    seems like I shouldn't have taken the advice for granted. primality check seems to work pretty descent.

  • Custom User Avatar

    Because he is passing number as a reference.
    This would mean if he would change number in the body of opposite, the value would be also manipulated outside the function.
    This is clearly not wanted.
    const declares that number will be treated as constant in this function and has two purposes:

    • the caller knows that even though he is passing number as a reference, it will not be changed
    • the programmer of opposite can not accidently change number as this would result into a compilation error.