0

This might be an easy question for some... I understand mod when the number before the % sign is greater than the number after it eg, 25%10=5. However I don't understand when the number before the % is smaller than the number after it for eg... 3%26. Because in my text it says 3%26=3,whereas according to me it should be 2.Please help.

ansh
  • 3
  • 1
  • 1
    Possible duplicate of [How does a modulo operation work when the first number is smaller?](https://stackoverflow.com/questions/1535656/how-does-a-modulo-operation-work-when-the-first-number-is-smaller) – Mika Sundland Jan 08 '18 at 00:39

1 Answers1

0

You can think of the operator as "find the remainder".

What happens when 26 % 3? You get 3 * 8 = 24, which creates a remainder of 2.

In the case of 3 % 26, 26 divides 3 exactly 0 times. 3 - 0 = 3, creating a remainder of 3.

aphrid
  • 589
  • 8
  • 25
  • No problem! If this answer helped you out, could you please hit the checkmark to set it as the accepted answer? Many thanks! – aphrid Jan 08 '18 at 00:24