?
Solved

Inverse Modular

Posted on 2003-02-23
10
Medium Priority
?
298 Views
Last Modified: 2010-05-18
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!
0
Comment
Question by:Emilio06
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 9

Expert Comment

by:tinchos
ID: 8004127
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
 
LVL 8

Expert Comment

by:Exceter
ID: 8004570
0
 
LVL 3

Expert Comment

by:CoolBreeze
ID: 8005370
you are fast Exceter!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:Exceter
ID: 8005416
I am? Thanks!
0
 

Author Comment

by:Emilio06
ID: 8005909
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
 
LVL 8

Accepted Solution

by:
Exceter earned 550 total points
ID: 8006059
>> 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
 

Author Comment

by:Emilio06
ID: 8017431
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
 
LVL 8

Expert Comment

by:Exceter
ID: 8017568
Why the C? You asked for help with the math and that is exactly what I gave you.
0
 

Author Comment

by:Emilio06
ID: 8021576
meh you got your points
0
 
LVL 8

Expert Comment

by:Exceter
ID: 8021773
But why the C?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question