## the mathematics of clocks [closed]

I'm searching for an elegant way to increment and decrement around a 'circle' of numbers like a clock.

Assuming the numbers 1,2,3 are my set of numbers on the clockface I want to perform the following mathematical operations:

1 + 1 = 2
1 + 2 = 3
1 + 3 = 1

1 - 1 = 3

I'm sure there must be a name for this kind of math, and lots of tricks for performing these calculations using the 'normal' rules of arithmetic. Looking for pointers as to what field of math studies these problems, or a set of simple/fast algorithms for doing the 'wrapping'.

-
You're looking for 'Modular arithmetic'. However, this question would be better suited for math.stackexchange; this site is intended for research-level questions. – Simon Rose Jan 5 2012 at 18:45
Look up "clock arithmetic". Then "modulo arithmetic", followed by "modular arithmetic". If you are writing your own software package, check the (e.g. Python) language repository for implementations/test suites. If programming is your goal, you should ask this question in a programming forum. Gerhard "Ask Me About System Design" Paseman, 2012.01.05 – Gerhard Paseman Jan 5 2012 at 18:46
Thx Simon, Gerhard for both answering my question, and for pointing me to the right venue. :) – Matt Taylor Jan 5 2012 at 19:33