حاسبة باقي القسمة (a mod n)
تجد هذه الحاسبة a mod n، أي باقي قسمة a على n، لأي أعداد صحيحة بما فيها السالبة. وتعرض ناتج القسمة والطرح والفرق بين الإجابة الرياضية وعامل % في بعض لغات البرمجة.
النتيجة
أدخل القيم واضغط احسب لرؤية النتيجة.
الصيغة
Divide, round down to a whole number, multiply back and subtract. For n > 0 the answer is between 0 and n − 1.
كيفية استخدام هذه الحاسبة
- Enter the number a and the modulus n (whole numbers; n cannot be 0).
- Press Calculate to see a mod n, the quotient and each step.
أمثلة محلولة
17 mod 5
17 ÷ 5 = 3.4, which rounds down to 3.
17 − 5 × 3 = 2, so 17 mod 5 = 2.
−17 mod 5 (a negative number)
−17 ÷ 5 = −3.4, which rounds down to −4.
−17 − 5 × (−4) = 3, so −17 mod 5 = 3. (The % operator in C or JavaScript gives −2.)
100 mod 7
100 ÷ 7 = 14.28…, so the quotient is 14.
100 − 7 × 14 = 2.
أخطاء شائعة
- Giving the quotient instead of the remainder: 17 mod 5 is 2, not 3.
- Rounding −3.4 to −3 instead of down to −4 for negative numbers.
- Expecting the same answer from % in every programming language; they differ for negatives.
الأسئلة الشائعة
What does mod mean in math?
a mod n is the remainder when a is divided by n. For example 17 mod 5 = 2, because 17 = 3 × 5 + 2.
How do you calculate mod of a negative number?
Divide and round down (towards negative infinity), then subtract. −17 mod 5: −17 ÷ 5 = −3.4 → −4, and −17 − 5 × (−4) = 3.
Where is modulo used?
Clock arithmetic (14:00 is 2 pm because 14 mod 12 = 2), checking whether a number is even (n mod 2), check digits, and programming.