Skip to main content
Home
plus.maths.org

Secondary menu

  • My list
  • About Plus
  • Sponsors
  • Subscribe
  • Contact Us
  • Log in
  • Main navigation

  • Home
  • Articles
  • Collections
  • Podcasts
  • Maths in a minute
  • Puzzles
  • Videos
  • Topics and tags
  • For

    • cat icon
      Curiosity
    • newspaper icon
      Media
    • graduation icon
      Education
    • briefcase icon
      Policy

      Popular topics and tags

      Shapes

      • Geometry
      • Vectors and matrices
      • Topology
      • Networks and graph theory
      • Fractals

      Numbers

      • Number theory
      • Arithmetic
      • Prime numbers
      • Fermat's last theorem
      • Cryptography

      Computing and information

      • Quantum computing
      • Complexity
      • Information theory
      • Artificial intelligence and machine learning
      • Algorithm

      Data and probability

      • Statistics
      • Probability and uncertainty
      • Randomness

      Abstract structures

      • Symmetry
      • Algebra and group theory
      • Vectors and matrices

      Physics

      • Fluid dynamics
      • Quantum physics
      • General relativity, gravity and black holes
      • Entropy and thermodynamics
      • String theory and quantum gravity

      Arts, humanities and sport

      • History and philosophy of mathematics
      • Art and Music
      • Language
      • Sport

      Logic, proof and strategy

      • Logic
      • Proof
      • Game theory

      Calculus and analysis

      • Differential equations
      • Calculus

      Towards applications

      • Mathematical modelling
      • Dynamical systems and Chaos

      Applications

      • Medicine and health
      • Epidemiology
      • Biology
      • Economics and finance
      • Engineering and architecture
      • Weather forecasting
      • Climate change

      Understanding of mathematics

      • Public understanding of mathematics
      • Education

      Get your maths quickly

      • Maths in a minute

      Main menu

    • Home
    • Articles
    • Collections
    • Podcasts
    • Maths in a minute
    • Puzzles
    • Videos
    • Topics and tags
    • Audiences

      • cat icon
        Curiosity
      • newspaper icon
        Media
      • graduation icon
        Education
      • briefcase icon
        Policy

      Secondary menu

    • My list
    • About Plus
    • Sponsors
    • Subscribe
    • Contact Us
    • Log in
    • Maths in a minute: Modular arithmetic

      1 April, 2015
      Clock

      You do modular arithmetic several times every day when you are thinking about time. Imagine, for example, you're going on a train trip at 11pm that lasts three hours. What time will you arrive? Not at 11+3 = 14 o'clock, but at 2 o'clock in the morning. That's because, on a 12-hour clock, you start counting from the beginning again after you get to 12. (On a 24-hour clock, you start again after you get to 24.) So, on a 12-hour clock you have:

      4 + 9 = 1,
      7 + 7 = 2,
      5 + 12 = 5,

      and so on. When you are subtracting hours, you do the same but backwards:

      4 - 7 = 9
      1 - 11 = 2
      6 - 12 = 6.

      You could play the same game using other numbers, apart from 12 and 24, to define your cycle. For example, in modular arithmetic modulo 5 you have

      4 + 2 = 1
      3 + 4 = 2
      1 - 4 = 2
      3 - 5 = 3

      These sums can be a little tedious to work out if you're counting on your fingers, but luckily there is a general method. Let's say you're doing arithmetic modulo some natural number p and you're looking at some other natural number x. To find the value of x modulo p (the value of x on a clock with p hours), compute the remainder when dividing x by p: that's your result.

      This also works when x is negative (noting that the remainder is defined to be always positive). For example, for p = 12 and x = -3 we have

      -3 = (-1) x 12 + 9,

      so the remainder is 9. Therefore -3 modulo 12 is equal to 9. (If you use the modulus function in some computer languages you have to be a little careful though, as some return a different value for negative numbers.)

      If you want to add or subtract two numbers module some natural number p, you simply work out the result, call it x, in ordinary arithmetic and then find the value of x modulo p.

      There is clearly something very cyclical about modular arithmetic. Whatever number p defines your arithmetic, you can think of it as counting forward or backward in clock with p hours. To put this in technical maths language, modular arithmetic modulo p gives you a cyclic group of order p. You can find out more about group theory in this article and about modular arithmetic on our sister site NRICH.

      Read more about...
      modular arithmetic
      Maths in a minute
      • Log in or register to post comments

      math.nights

      26 February 2016

      Permalink

      The article translated into Arabic: https://goo.gl/evtTq8

      • Log in or register to post comments

      Read more about...

      modular arithmetic
      Maths in a minute
      University of Cambridge logo

      Plus Magazine is part of the family of activities in the Millennium Mathematics Project.
      Copyright © 1997 - 2025. University of Cambridge. All rights reserved.

      Terms