Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

greatest common divisor (x c y , z)

Status
Not open for further replies.

smslca

Member level 1
Member level 1
Joined
Sep 9, 2007
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,656
can we find the value of gcd(x c y , z) easily and very fast using a computer.

where
1. "c" represents "combinations" used in 'permutations and combinations'.
2. x is very very large number (ex: may be of 100 or 1000 numerical digits)
3. y is also large having 2 to 5 digits less than x.
4. z is also large having the same number of digits as x.
 

I hope I am getting the question right, but yes, you can get a fast and correct answer to finding the GCD of xCy and z. Write a program, preferably in C/C++ (preferably just because I like it :D ). In the code, make a function for xCy , for eg: int xCy ( int x, int y). Return the value in a variable, int combi; (you can ofcourse use float too)
Then define the GCD function. Eg: int GCD ( combi , int z);

Alternatively you can also call xCy() from GCD() directly as a parameter.
 

GCD is trivial:

int GCD(int a, int b)
{
while( 1 )
{
a = a % b;
if( a == 0 )
return b;
b = b % a;

if( b == 0 )
return a;
}
}

Your problem is the C++ does mathematical calculations on 32 or 64 bit data.
What you need is a large number library to support 1000 digit numbers.
I recommend:
https://mattmccutchen.net/bigint/
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top