> Create a program that can find all values of x in the set of m for the equation of the form ax(modm)= b?

Create a program that can find all values of x in the set of m for the equation of the form ax(modm)= b?

Posted at: 2014-12-18 
Take a, b, and m as input. Multiply a by each of the numbers 0,1,2,3,...,m-1 and take the remainder modulo m. If it is b, you have a solution.

b = b%m;

for(int i = 0; i < m; i++)

{

if((i*a) % m == b)

**add i to solution set**

}

I am trying to create this program for my computer science class. I am not a computer science major and all I could come up with was this :

#include

using namespace std;

int main()

{

int a, b, n, x;

int m = (n / b);



cout << " enter a value for a: " << endl;

cin >> a;

cout << "Enter value for b: " << endl;

cin >> b;

cout << "Enter value for m: " << endl;

cin >> m;

n = m / b;

x = n * b;

return x;

}