Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Copy edited.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134
0 % 3 = 0; 1 % 3 = 1; 2 % 3 = 2; 3 % 3 = 0; 

Did you see what it did? atAt the last step it went back to zero. This This could be used in situations like:

  1. toTo check if N is divisible by M (eg:for example, odd or even.) or N is a multiple of M.

  2. toTo put a cap of a particular value. inIn this case 3.

  3. toTo get the last M digits of a number -> N % (10^M).

0 % 3 = 0; 1 % 3 = 1; 2 % 3 = 2; 3 % 3 = 0; 

see what it did? at the last step it went back to zero. This could be used in situations like

  1. to check if N is divisible by M (eg: odd even.) or N is a multiple of M

  2. to put a cap of a particular value. in this case 3

  3. to get the last M digits of a number -> N % (10^M)

0 % 3 = 0; 1 % 3 = 1; 2 % 3 = 2; 3 % 3 = 0; 

Did you see what it did? At the last step it went back to zero. This could be used in situations like:

  1. To check if N is divisible by M (for example, odd or even) or N is a multiple of M.

  2. To put a cap of a particular value. In this case 3.

  3. To get the last M digits of a number -> N % (10^M).

added 34 characters in body
Source Link
SysAdmin
  • 5.6k
  • 8
  • 35
  • 34
0 % 3 = 0; 1 % 3 = 1; 2 % 3 = 2; 3 % 3 = 0; 

see what it did? at the last step it went back to zero. This could be used in situations like

  1. to check if N is divisible by M (eg: odd even.)

    to check if N is divisible by M (eg: odd even.) or N is a multiple of M

  2. to put a cap of a particular value. in this case 3

    to put a cap of a particular value. in this case 3

  3. to get the last M digits of a number -> N % (10^M)

    to get the last M digits of a number -> N % (10^M)

0 % 3 = 0; 1 % 3 = 1; 2 % 3 = 2; 3 % 3 = 0; 

see what it did? at the last step it went back to zero. This could be used in situations like

  1. to check if N is divisible by M (eg: odd even.)
  2. to put a cap of a particular value. in this case 3
  3. to get the last M digits of a number -> N % (10^M)
0 % 3 = 0; 1 % 3 = 1; 2 % 3 = 2; 3 % 3 = 0; 

see what it did? at the last step it went back to zero. This could be used in situations like

  1. to check if N is divisible by M (eg: odd even.) or N is a multiple of M

  2. to put a cap of a particular value. in this case 3

  3. to get the last M digits of a number -> N % (10^M)

Source Link
SysAdmin
  • 5.6k
  • 8
  • 35
  • 34

0 % 3 = 0; 1 % 3 = 1; 2 % 3 = 2; 3 % 3 = 0; 

see what it did? at the last step it went back to zero. This could be used in situations like

  1. to check if N is divisible by M (eg: odd even.)
  2. to put a cap of a particular value. in this case 3
  3. to get the last M digits of a number -> N % (10^M)