Free to use, no account

Modulo-kalkulator

Beregn kvotient og rest for heltall. Negative inndata håndteres konsekvent, og divisjonsidentiteten viser hvordan svaret blir til.

Tallet som skal deles; det kan være negativt.

Bruk et helt tall som ikke er null; absoluttverdien definerer modulus.

Kontroller om denne verdien er kongruent med dividenden modulo divisoren.

Godtar fortegnede heltall på opptil 50 sifre. Brøker og desimaltall støttes ikke. Resultatet bruker euklidsk modulo; enkelte programmeringsspråk bruker en annen regel for rest ved negative tall.

Hvordan beregner jeg modulo med et negativt tall?

Kalkulatoren bruker en ikke-negativ rest som er mindre enn divisorens absoluttverdi. For eksempel er −7 mod 3 lik 2 fordi −7 = (−3 × 3) + 2.

Veiledning

Slik bruker du modulo-calculator

The Modulo Calculator divides one whole number by another and shows the quotient and the remainder. The remainder is never negative and always smaller than the size of the divisor, even when you enter negative numbers. You can add a third number to test whether it is congruent to the first. It handles whole numbers of up to 50 digits.

Slik gjør du

  1. Type the dividend, which is the number being divided. It can be negative, and it must be a whole number with no decimals.
  2. Type the divisor. Any whole number except zero works, and its size without the sign becomes the modulus. Add a comparison value if you want a congruence check.
  3. Press Calculate modulo to fill the results table, then press Copy results to take the text with you. The example button loads -7, 3 and 2 and runs them.

Eksempler

A negative dividend

Du skriver inn
Dividend
-7
Divisor
3
Sammenlign
2
Du får
Kvotient
-3
Rest
2
Identitet
-7 = -3 × (3) + 2
Område
0 ≤ 2 < 3
Kongruens
-7 ≡ 2 (mod 3)

Three goes into -7 a total of -3 times, which lands at -9, so 2 is left over to reach -7. The remainder is 2, not -1, and 2 matches the comparison value.

Kjørt med verktøyets egen kode.

A negative divisor

Du skriver inn
Dividend
12
Divisor
-5
Sammenlign
-3
Du får
Modulus
5
Kvotient
-2
Rest
2
Identitet
12 = -2 × (-5) + 2
Kongruens
12 ≡ -3 (mod 5)

The sign of the divisor changes the quotient but not the remainder, because the modulus is the divisor without its sign. The difference between 12 and -3 is 15, which five divides evenly.

Kjørt med verktøyets egen kode.

Numbers that are not congruent

Du skriver inn
Dividend
100
Divisor
7
Sammenlign
3
Du får
Kvotient
14
Rest
2
Område
0 ≤ 2 < 7
Kongruens
100 ≢ 3 (mod 7)

Fourteen sevens make 98, which leaves 2. The comparison value 3 is not 2 modulo 7, so the table shows the not-congruent sign instead of the tick.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Check homework on remainders, clock arithmetic or divisibility rules with the full working shown.
  • Find which weekday, seat or position comes up after a number of steps in a repeating cycle.
  • See what a mathematical remainder looks like for a negative number before you compare it with code output.
  • Test whether two large whole numbers fall in the same residue class for a given modulus.

Begrensninger

  • Only whole numbers are accepted, each between minus 10^50 and 10^50, so fractions, decimals and longer numbers are rejected.
  • The divisor cannot be zero. Any rejected input shows one general message asking you to check the fields, not a separate message for each problem.
  • The tool always uses the non-negative remainder rule. Some programming languages return a negative remainder for a negative dividend, so their result can differ from this one.

Tips

  • Read the identity line, dividend = quotient × divisor + remainder, and multiply it out by hand once to be sure you follow the sign handling.
  • When your code gives a different answer for a negative number, add the modulus to the code result until it falls in the range shown here.
  • Use the comparison box to check that two numbers belong together without working out each remainder separately.

Vanlige spørsmål

What does modulo mean?

Modulo gives the remainder left after dividing one whole number by another. Here, 100 modulo 7 is 2, because 14 sevens make 98 and 2 is left over. The tool also shows the quotient and the full division line.

How does the calculator treat negative numbers?

It picks the remainder that is zero or more and smaller than the divisor's size. For -7 and 3, the quotient is -3 and the remainder is 2, since -3 times 3 is -9 and -9 plus 2 is -7.

Why does my programming language give a different answer?

Some languages keep the sign of the dividend in the remainder, so -7 % 3 gives -1 in JavaScript. This tool returns 2 instead. Adding the modulus to the language result brings the two into agreement.

What does congruent modulo m mean?

Two whole numbers are congruent modulo m when their difference divides evenly by m. The optional comparison box checks that exactly and writes the result with an equals-like sign or a crossed-out one.

What happens if the divisor is negative?

The modulus is the divisor without its sign, so dividing by -5 uses 5 for the remainder range. Only the quotient changes sign. For 12 and -5 the remainder stays 2 and the quotient is -2.

Is my data sent anywhere?

No. The sums run in your browser, and the page says the numbers are not uploaded or saved. Copy the result text before you leave if you want to keep it.

Kilder

Ofte stilte spørsmål

Hvordan beregner jeg modulo med et negativt tall?

Kalkulatoren bruker en ikke-negativ rest som er mindre enn divisorens absoluttverdi. For eksempel er −7 mod 3 lik 2 fordi −7 = (−3 × 3) + 2.

Lastes tallene mine opp?

Nei. Den nøyaktige beregningen kjøres i denne nettleseren. Tallene lastes ikke opp eller lagres.

Hva er −7 mod 3?

Med Euklids konvensjon er −7 mod 3 lik 2: −7 = (−3 × 3) + 2, og 0 ≤ 2 < 3.

Hva betyr kongruent modulo m?

To heltall er kongruente modulo m når differansen deres er delelig med |m|. Den valgfrie sammenligningen kontrollerer dette nøyaktig.

Hvorfor kan dette avvike fra %-operatoren i et programmeringsspråk?

Noen språk beholder fortegnet til en negativ dividend i resten. Denne kalkulatoren returnerer i stedet en rest fra 0 og opp til, men ikke inkludert, divisorens absoluttverdi.