CODE IN C++
#include<iostream>
using namespace std;
int GCD(int a, int b, int *x, int *y)
{
if (a == 0)
{
*x = 0, *y = 1;
return b;
}
int x1, y1;
int gcd = GCD(b%a, a, &x1, &y1);
*x = y1 - (b/a) * x1;
*y = x1;
return gcd;
}
void modInverse(int a, int m)
{
int x, y;
int g = GCD(a, m, &x, &y);
if (g != 1)
cout << "Inverse does nOt exist!!";
else
{
int res = (x%m + m) % m;
cout << "Modular inverse is " << res;
}
}
// Driver Program
int main()
{
int a, n;
cout << "Enter the value of n: ";
cin >> n;
cout << "Enter the value of a (>= 0): ";
cin >> a;
modInverse(a, n);
return 0;
}
Project 2: The Inverse Modulo n [MOD] Textbook Section: 7.37 Directions: The user will input the...