Modulo Rechner

Reste berechnen, modulare Rechenoperationen, Kongruenzen und Uhren-Arithmetik.

Was ist Modulo?

The modulo operation (written as a mod m or a % m) returns the remainder when integer a is divided by integer m (the modulus). It is based on the division algorithm: for any integers a and m (m>0), there exist unique integers q (quotient) and r (remainder) such that a = q × m + r where 0 ≤ r < m.

Modular arithmetic is sometimes called clock arithmetic because of its cyclic nature — just like hours on a clock wrap around from 12 back to 1. It underpins modern cryptography (RSA, Diffie-Hellman), hash functions, checksums, cyclic data structures, and calendar calculations (what day of the week is a given date?).

Floor vs Truncated modulo: For positive numbers both give the same result. For negative numbers they differ. Python uses floor division: −7 mod 3 = 2 (always non-negative). C, Java, and JavaScript use truncated division: −7 % 3 = −1 (sign matches the dividend). Mathematically the floor version is more consistent with number theory.

Modulo vs Remainder — Negative Number Comparison

AusdruckBoden (Python)Abgeschnitten (C/JS)
17 mod 522
-7 mod 32-1
7 mod -3-21
-7 mod -3-1-1

Häufig gestellte Fragen

Modulo gibt den Rest nach der Division einer Zahl durch eine andere zurück. Für 17 mod 5: 17 = 3×5 + 2, also ist das Ergebnis 2. Es ist die Grundlage der modularen Arithmetik.
Bei positiven Zahlen sind sie identisch. Bei negativen Zahlen gibt Bodenmodulo (Python) immer ein nicht-negatives Ergebnis zurück, während abgeschnittener Rest (C, Java, JavaScript %) negativ sein kann.
Modulare Arithmetik ist ein Zahlensystem, bei dem Zahlen beim Erreichen eines bestimmten Werts (des Modulus) wieder von vorne beginnen. Denk an eine Uhr: nach 12 geht es zurück zu 1.
Das modulare Inverse von a modulo m ist eine Zahl x mit (a × x) ≡ 1 (mod m). Es existiert nur, wenn ggT(a, m) = 1. Es wird mit dem erweiterten Euklidischen Algorithmus berechnet.
RSA-Verschlüsselung basiert auf modularer Exponentiation: Geheimtext = Nachricht^e mod n. Die Sicherheit beruht auf der Schwierigkeit diskreter Logarithmen und Ganzzahlfaktorisierung.
Uhren-Arithmetik ist Arithmetik modulo 12 (oder 24). Wenn es 10 Uhr ist und man 5 Stunden addiert: (10 + 5) mod 12 = 3. Das gleiche Prinzip gilt für zyklische Puffer und Hash-Tabellen.
This notation means a and b are congruent modulo m: they have the same remainder when divided by m, or equivalently, m divides (a − b). Example: 17 ≡ 5 (mod 6) because both give remainder 5 when divided by 6 (17 − 5 = 12 = 6×2).
0 mod m = 0 for any non-zero m, since 0 = 0 × m + 0. The remainder is always 0. Division by zero (a mod 0) is undefined.

Ähnliche Rechner