# Inverse Modular

Hi,

I'm studying C++ and I have to create a program that caculates the inverse modular using two numbers as inputs ( x and m ) and one output ( n ), the inverse modular.

Can anyone give me a hand with the math behind it?

Thanks!
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
hi

i'm from argentina, and i'm not so familiar with maths expresions

so, if you clarify what inverse modular is maybe i can help you
0
Commented:
0
Commented:
you are fast Exceter!
0
Commented:
I am? Thanks!
0
Author Commented:
Exceter, can you please demonstrate the process in the link you've given my in your own words, using the variables i defined?

Thanks.
0
Commented:
>> Exceter, can you please demonstrate the process in the link you've given my in your own words, using the variables i defined?

I don't think I can do a better job than did Doctor Wilkinson. That was a pretty good explanation.

Exceter
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:

btw this is the function:

int modinverse(int x,int n)

{                                           int kn,a,la,q,t;
kn=n;
x%=n;
if (x<0) x+=n;
a=1;      la=0;
while (x>1)
{                                      q=n/x;
t=la-a*q; la=a; a=t;
t=n-x*q;  n=x;  x=t;
}
if   (x==0) return 0;
if (a<0) a+=kn;

return a;
}
0
Commented:
Why the C? You asked for help with the math and that is exactly what I gave you.
0
Author Commented:
0
Commented:
But why the C?
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.