Grok-Pedia

mod

Modulo Operation

The modulo operation, often abbreviated as "mod," is a mathematical operation that finds the remainder after division of one number by another. It is represented by the symbol "%" or "mod" in many programming languages.

Mathematical Definition

In mathematical terms, for two integers \(a\) and \(n\), \(a \mod n\) is defined as the remainder when \(a\) is divided by \(n\). If \(a = nq + r\) where \(q\) is the quotient and \(r\) is the remainder, then:

History

The concept of modulus or remainder can be traced back to ancient times, but the term "mod" in its modern context was popularized by the work of mathematicians like Carl Friedrich Gauss. Gauss used modular arithmetic extensively in his work on number theory, particularly in his book "Disquisitiones Arithmeticae" published in 1801.

Applications

Properties

Programming Examples

In most programming languages, the modulo operation can be performed with the % operator:


int result = 17 % 5; // result will be 2

External Links

Related Topics

Recently Created Pages