# Calculator

For the Euclidean Algorithm, Extended Euclidean Algorithm and multiplicative inverse.

#### Before you use this calculator

If you're used to a different notation, the output of the calculator might confuse you at first.

Even though this is basically the same as the notation you expect. If that happens, don't panic.

Just make sure to have a look the following pages first and then it will all make sense:

- Euclidean Algorithm

For the basics and the table notation - Extended Euclidean Algorithm

Unless you only want to use this calculator for the basic Euclidean Algorithm. - Modular multiplicative inverse

in case you are interested in calculating the modular multiplicative inverse of a number modulo n

using the Extended Euclidean Algorithm

**Input**

**Algorithm**

Choose which algorithm you would like to use.

**Numbers**

Enter the input numbers. Note that you need to enter n before b.

E.g. if you want to know the multiplicative inverse of 26 mod 11, then use n=11 and b=26.

#### Output

**Note:**5219 mod 641 ≡ 91, so you could also use this calculator with n=641 and b=91. In that case the table will have less rows, even though it has the same multiplicative inverse.

**5219 mod 641**using the Extended Euclidean Algorithm:

n | b | q | r | t1 | t2 | t3 |
---|---|---|---|---|---|---|

641 | 5219 | 0 | 641 | 0 | 1 | 0 |

5219 | 641 | 8 | 91 | 1 | 0 | 1 |

641 | 91 | 7 | 4 | 0 | 1 | -7 |

91 | 4 | 22 | 3 | 1 | -7 | 155 |

4 | 3 | 1 | 1 | -7 | 155 | -162 |

3 | 1 | 3 | 0 | 155 | -162 | 641 |

**Answer**

So t = -162. Now we still have to apply mod n to that number:

-162 mod 641 ≡ 479

So the multiplicative inverse of 5219 modulo 641 is 479.

**Verification**

Let **i** be the answer we just found, so i=479. We also have b=5219 and n=641.

If our answer is correct, then `i × b (mod n) ≡ 1 (mod n)`

.

Let's see if that's indeed the case.

i × b (mod n) ≡

479 × 5219 (mod 641) ≡

2499901 (mod 641) ≡

1 (mod 641)

`i × b (mod n) ≡ 1 (mod n)`

, so our calculation is correct!