What is modular arithmetic? (article) | Khan Academy (2024)

Want to join the conversation?

Log in

  • Kiara O'Connell

    11 years agoPosted 11 years ago. Direct link to Kiara O'Connell's post “In the last example, the ...”

    In the last example, the answer is 1. I understand how you got the answer using the clock, but I thought the point of the modulo operator was to find the remainder, and if you divide -5 by 3, the remainder would be 2. Why are these answers different??

    (132 votes)

    • Cameron

      11 years agoPosted 11 years ago. Direct link to Cameron's post “It is true that 5 divided...”

      What is modular arithmetic? (article) | Khan Academy (4)

      What is modular arithmetic? (article) | Khan Academy (5)

      What is modular arithmetic? (article) | Khan Academy (6)

      It is true that 5 divided by 3 gives you a remainder of 2
      However, it is NOT true that -5 divided by 3 gives you a remainder of 2. It gives you a remainder of 1.

      We can do some long division to prove it:

      First we'll do the simple 5/3

       _1_R2
      3 / 5
      -3 (Since 1 * 3 = 3)
      ---
      2

      We can check our result:
      5 = 1 * 3 + 2

      Now we can do -5/3

       _-2_R1
      3 / -5
      -(-6) (Since -2 * 3= -6)
      ---
      1

      We can check our result:
      -5 = -2 * 3 + 1

      The -2 seems strange since we might think 3 goes into 5, -1 times. But this would make our remainder negative (which is not allowed)

      Let's see what would happen, if we allowed negative remainders (we don't, but computers do!) it would look like this:

       _-1_R-2
      3 / -5
      -(-3) (Since -1 * 3= -3)
      ---
      -2

      We can check our result:
      -5 = -1 * 3 + (-2)

      Notice that if we go 2 steps counter clockwise on the modular circle for 3 that we end up at 1.
      Notice that if we add one multiple of 3 to -2 we end up at 1.
      Again, we don't allow negative remainders, but it may give you some intuition for what is going on, and for how congruence modulo works later.

      Hope this makes sense

      (307 votes)

  • Shane Kays

    11 years agoPosted 11 years ago. Direct link to Shane Kays's post “Who invented Modular Arit...”

    Who invented Modular Arithmetic?

    (22 votes)

    • Cameron

      11 years agoPosted 11 years ago. Direct link to Cameron's post “Johann Carl Friedrich Gau...”

      What is modular arithmetic? (article) | Khan Academy (10)

      What is modular arithmetic? (article) | Khan Academy (11)

      What is modular arithmetic? (article) | Khan Academy (12)

      Johann Carl Friedrich Gauss is usually attributed with the invention/discovery of modular arithmetic. In 1796 he did some work that advanced the field, and in 1801 published the book Disquisitiones Arithmeticae which, amongst other things, introduced congruence modulo and the ≡ symbol. So he is the person that laid out the modern approach to modular arithmetic that we use today.

      Gauss is one of the most influential mathematicians of all time. His name is well known amongst mathematicians.

      (87 votes)

  • diana

    10 years agoPosted 10 years ago. Direct link to diana's post “-17 mod 7-7*2=-14-17 '...”

    -17 mod 7

    -7*2=-14
    -17 '=' -7 *2 +-3

    -7 *2 +-3=-17

    why does the site say 4? :(

    (9 votes)

    • Alex Carrasquillo

      9 years agoPosted 9 years ago. Direct link to Alex Carrasquillo's post “You said -7 *2 = -14, but...”

      What is modular arithmetic? (article) | Khan Academy (16)

      What is modular arithmetic? (article) | Khan Academy (17)

      What is modular arithmetic? (article) | Khan Academy (18)

      You said -7 *2 = -14, but -14 is actually bigger than -17. We have to go a little further. The next step would be -7*3 = -21, which is smaller than -17. Now from -21, how much do we need to add to get to -17? The answer is 4. Hope this helped! :)

      (53 votes)

  • vijayhm

    10 years agoPosted 10 years ago. Direct link to vijayhm's post “What happens if the modul...”

    What happens if the modulus is negative?

    (14 votes)

    • Cameron

      10 years agoPosted 10 years ago. Direct link to Cameron's post “The modulus must be a pos...”

      What is modular arithmetic? (article) | Khan Academy (22)

      What is modular arithmetic? (article) | Khan Academy (23)

      The modulus must be a positive integer i.e. an integer > = 1

      (28 votes)

  • MohsenQaddoura

    8 years agoPosted 8 years ago. Direct link to MohsenQaddoura's post “Is the following method (...”

    Is the following method (I devised it by observation ) a known / valid method of getting the negative integers reminder?
    if A % B = C
    then -A % B = B - C

    ex: -19 % 4 can be solved with these steps:
    19 % 4 = 3
    -19 % 4 = 4 - 3 = 1

    If valid but not known previously attribute it to me please. all rights reserved.

    (15 votes)

    • Cameron

      8 years agoPosted 8 years ago. Direct link to Cameron's post “Yes, it works. It's a coo...”

      What is modular arithmetic? (article) | Khan Academy (27)

      Yes, it works. It's a cool discovery, but you weren't the first one to discover it.

      Here's a simple explanation of how it works.
      For our mod n circle.
      - positive numbers go clockwise around the circle
      - negative numbers go anti-clockwise around the circle
      To find where a number has ended up on the circle, in clockwise units, if you have a number measured in anti-clockwise units you have:
      #clockwise_units = size_of_circle - #anti_clockwise_units
      Remember that the size of the circle for mod n is n.

      Later on, you will find that -x (mod n) is congruent to n-x (mod n).

      Hope this makes, and good luck with more discoveries

      (23 votes)

  • The Great Narwhal

    11 years agoPosted 11 years ago. Direct link to The Great Narwhal's post “Can someone explain the c...”

    Can someone explain the concept of calculating mod with out the circles?
    How would you do 13 mod 10?

    (3 votes)

    • Noble Mushtak

      11 years agoPosted 11 years ago. Direct link to Noble Mushtak's post “13 mod 10. 1 R 31...”

      What is modular arithmetic? (article) | Khan Academy (31)

      13 mod 10.
      1 R 3
      10/13
      10
      3
      The remainder is 3. 13 mod 10 is 3.
      I think this method of modulus is easier than the modulus method. What do you think?

      (13 votes)

  • shaillie.tiwari532st

    8 years agoPosted 8 years ago. Direct link to shaillie.tiwari532st's post “how is 3mod10 = 3?? it sh...”

    how is 3mod10 = 3?? it should be 0..isnt it??

    (5 votes)

    • Cameron

      8 years agoPosted 8 years ago. Direct link to Cameron's post “3 / 10 = 0 with a remaind...”

      3 / 10 = 0 with a remainder of 3
      3 mod 10 gives us the remainder when we divide 3 by 10.
      Thus 3 mod 10 = 3

      (6 votes)

  • yamauchi.hitoshi

    11 years agoPosted 11 years ago. Direct link to yamauchi.hitoshi's post “It seems a typo that '(5 ...”

    It seems a typo that '(5 is negative)' just under the -5 mod 3 = ?. I think 5 is a positive number, -5 is negative. (I have already asked this at Crowdin, but no answer for three weeks. )
    Best,
    H.

    (2 votes)

    • Cameron

      11 years agoPosted 11 years ago. Direct link to Cameron's post “Indeed, 5 is a positive n...”

      Indeed, 5 is a positive number, and -5 is a negative number.

      However, for the example:
      "-5 mod 3 = ?
      With a modulus of 3 we we make a clock with numbers 0,1,2
      We start at 0 and go through 5 numbers in counter-clockwise sequence (5 is negative) 2,1,0,2,1"

      The "(5 is negative)" is explaining why we are going counter-clockwise as opposed to clockwise
      i.e. if we were looking at 5 mod 3 we would start at 0 and go through 5 numbers in a clockwise sequence, (1,2,0,1,2) but in the example we have -5 mod 3, so we start at 0 and go through 5 numbers in a counter-clockwise sequence (2,1,0,2,1)

      Hope this makes sense

      (8 votes)

  • kahmarg

    a year agoPosted a year ago. Direct link to kahmarg's post “still dont understand it ...”

    still dont understand it
    more example please

    (6 votes)

  • dbrodersen

    11 years agoPosted 11 years ago. Direct link to dbrodersen's post “There is no video. A cong...”

    There is no video. A congruent B (modulo C). Does this mean that when A or B is divided by C the remainder will be the same?

    (3 votes)

    • Cameron

      11 years agoPosted 11 years ago. Direct link to Cameron's post “You are correct when you ...”

      You are correct when you say
      if we have A ≡ B (mod C) then this will mean when A or B is divided by C the remainder will be the same

      For more info, check out:
      https://www.khanacademy.org/math/applied-math/cryptography/modarithmetic/a/congruence-modulo

      (6 votes)

What is modular arithmetic? (article) | Khan Academy (2024)
Top Articles
Latest Posts
Article information

Author: Greg O'Connell

Last Updated:

Views: 6192

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Greg O'Connell

Birthday: 1992-01-10

Address: Suite 517 2436 Jefferey Pass, Shanitaside, UT 27519

Phone: +2614651609714

Job: Education Developer

Hobby: Cooking, Gambling, Pottery, Shooting, Baseball, Singing, Snowboarding

Introduction: My name is Greg O'Connell, I am a delightful, colorful, talented, kind, lively, modern, tender person who loves writing and wants to share my knowledge and understanding with you.