Adição Modular is a mathematical operation that involves adding two integers and then taking the remainder when divided by a third integer known as the modulus. This operation is commonly used in various fields, including ciência da computação, cryptography, and number theory.
Matematicamente, a adição modular pode ser expressa como:
a + b (mod m)
Aqui, a and b are the integers being added, and m is the modulus. The result of the operation is the remainder of the sum a + b when divided by m.
Por exemplo, se quisermos realizar uma adição modular com a = 7, b = 5, and m = 6, we first add the two numbers:
7 + 5 = 12
Em seguida, encontramos o resto quando 12 é dividido por 6:
12 mod 6 = 0
Assim, 7 + 5 (mod 6) = 0.
A adição modular possui várias propriedades importantes, incluindo:
- Fechamento: The sum of any two integers under a given modulus will always yield another integer within the same modulus.
- Propriedade Associativa: A ordem na qual as adições são realizadas não afeta o resultado.
- Propriedade Comutativa: A soma permanece a mesma independentemente da ordem dos operandos.
Essas propriedades tornam a adição modular particularmente útil em algorithms where a fixed range of values is needed, such as in cyclic tasks, scheduling, and even in creating hash functions.