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!
Emilio06Asked:
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.

tinchosCommented:
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
ExceterCommented:
0
CoolBreezeCommented:
you are fast Exceter!
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

ExceterCommented:
I am? Thanks!
0
Emilio06Author 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
ExceterCommented:
>> 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

Your issues matter to us.

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

Start your 7-day free trial
Emilio06Author Commented:
thanks for your help,

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
ExceterCommented:
Why the C? You asked for help with the math and that is exactly what I gave you.
0
Emilio06Author Commented:
meh you got your points
0
ExceterCommented:
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.