Gratis å bruke, uten konto

Kalkulator for modulær invers

Finn tallet x slik at a × x gir rest 1 når det deles på m. Se om en invers finnes, største felles divisor og trinnene i den utvidede Euklids algoritme.

Bare heltallsregning; støttede absoluttverdier er opptil 1,000,000,000,000. En modulær invers finnes bare når gcd er 1.

Definisjon: a × x ≡ 1 (mod m).

Hvordan finner jeg en modulær invers?

Oppgi et heltall a og en modulus m på minst 2. En invers finnes nøyaktig når gcd(a, m) = 1. Resultatet normaliseres fra 0 til m − 1 og verifiseres ved multiplikasjon modulo m.

Veiledning

Slik bruker du Kalkulator for modulær invers

The Modular Inverse Calculator looks for a number x so that a times x leaves a remainder of 1 when divided by m. You enter a whole number a and a modulus m. The tool says whether such an x exists, gives the greatest common divisor, and lists the extended Euclidean steps behind the answer. It works with whole numbers only.

Slik gjør du

  1. Type the whole number a. It can be negative or larger than the modulus.
  2. Type the modulus m. It must be a whole number of at least 2.
  3. Press Calculate inverse. The result says whether an inverse exists, shows the gcd and a mod m, and, when there is an inverse, shows it with a check and the Bezout line.
  4. Read the numbered Euclidean steps below the result if you want to follow the working. Use Load 3 modulo 7 for a sample, or Clear to start over.

Eksempler

The sample from the page

Du skriver inn
a
3
m
7
Du får
Invers
5
Største felles divisor
1
Kontroll
3 × 5 ≡ 1 (mod 7)
Bezout
-2 × 3 + 1 × 7 = 1
Trinn
2

3 times 5 is 15, and 15 leaves remainder 1 when divided by 7. The Bezout line is a second proof: -6 plus 7 equals 1.

Kjørt med verktøyets egen kode.

A larger pair

Du skriver inn
a
17
m
3120
Du får
Invers
2753
Største felles divisor
1

17 times 2753 is 46801, which is 15 times 3120 plus 1. This pair is a common textbook case, and the tool finds the answer by the extended Euclidean method.

Kjørt med verktøyets egen kode.

A negative number

Du skriver inn
a
-4
m
9
Du får
a mod m
5
Invers
2
Største felles divisor
1

The tool first turns -4 into the residue 5 (mod 9). Then 5 times 2 is 10, which leaves remainder 1, so the inverse is 2.

Kjørt med verktøyets egen kode.

No inverse exists

Du skriver inn
a
6
m
9
Du får
Status
No inverse exists for these values
Største felles divisor
3
Melding
No inverse exists because the gcd is not 1.

6 and 9 share the factor 3. Any multiple of 6 and any multiple of 9 are both multiples of 3, so a product of 6 with a whole number can never sit exactly 1 above a multiple of 9.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Check homework on number theory or on solving congruences such as 3x ≡ 1 (mod 7).
  • Work out the decryption key d for a small RSA example from the public exponent and the totient.
  • Divide inside modular arithmetic, for example when a puzzle or a program works with remainders.
  • Learn the extended Euclidean algorithm by comparing your own steps with the tool's steps.

Begrensninger

  • Only whole numbers are accepted. The absolute value of a must be at most 1,000,000,000,000, and m must be from 2 to 1,000,000,000,000.
  • An inverse exists only when the gcd of a and m is 1. Otherwise the tool says none exists and does not give a partial answer.
  • The answer is the single value from 0 to m - 1. Any number that differs from it by a multiple of m is also an inverse, but the tool does not list those.
  • This is a learning and checking tool for small and medium numbers. It is not meant for the very large numbers used in real cryptographic keys.

Tips

  • Use the check line, for example 3 × 5 ≡ 1 (mod 7), to confirm the answer by hand.
  • If you get no inverse, look at the gcd. Dividing a and m by it can show you why they do not work together.
  • Compare the Bezout line with the steps to see how the coefficients grow from one step to the next.

Kilder

Vanlige spørsmål

How do I find a modular inverse?

Enter an integer a and a modulus m of at least 2, then press Calculate inverse. The tool uses the extended Euclidean algorithm. If the gcd of a and m is 1, it shows the inverse as a number from 0 to m - 1, with a check.

When does a modular inverse exist?

An inverse of a modulo m exists exactly when a and m are coprime, which means their greatest common divisor is 1. If the gcd is larger than 1, no whole number x can make a times x leave remainder 1.

What is the inverse of 3 modulo 7?

It is 5. Three times five is 15, and fifteen divided by seven leaves a remainder of 1. You can load this case with the Load 3 modulo 7 button.

What happens if a is negative or bigger than m?

The tool first reduces a to its remainder from 0 to m - 1. For -4 modulo 9 that remainder is 5. The reduction does not change whether an inverse exists, and the result row shows the reduced value.

What does the Bezout line mean?

It writes 1 as a mix of the reduced a and the modulus, such as -2 × 3 + 1 × 7 = 1. The number in front of a is the inverse, up to adding or removing multiples of m.

Why do I get a message about whole numbers and a modulus of at least 2?

The tool accepts only whole numbers with an absolute value up to 1,000,000,000,000, and the modulus must be 2 or more. Decimals, empty boxes and a modulus of 0 or 1 give that message.

Are my numbers sent anywhere?

No. The arithmetic runs in your browser, and the values are not uploaded or saved by the tool.

Hvordan finner jeg en modulær invers?

Oppgi et heltall a og en modulus m på minst 2. En invers finnes nøyaktig når gcd(a, m) = 1. Resultatet normaliseres fra 0 til m − 1 og verifiseres ved multiplikasjon modulo m.

Sendes tallene mine til en server?

Nei. Regnestykket kjøres i nettleseren, og verdiene lastes ikke opp eller lagres av dette verktøyet.

Hva er inversen av 3 modulo 7?

Svaret er 5 fordi 3 × 5 = 15, og 15 gir rest 1 når det deles på 7.

Når finnes en modulær invers?

Et heltall a har en invers modulo m nøyaktig når a og m er relativt primiske, det vil si at største felles divisor er 1.

Hva hvis inndataene er negative?

Kalkulatoren reduserer først a til standardresten fra 0 til m − 1. Dette endrer ikke om inversen finnes.