greatest common divisor (x c y , z)

Status
Not open for further replies.

smslca

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 ). 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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…