Math questions from any Manhattan Prep GMAT Computer Adaptive Test.
Eddie Gutia
Students
 
Posts: 43
Joined: Wed Aug 15, 2012 5:46 pm
 

Fastest way to calculate the GCF and LCM

by Eddie Gutia Wed Aug 22, 2012 10:39 pm

I was going through the MGMAT Number properties tutorial. I am wondering if there is an easy way to calculate LCM and GCF instead of using the method proposed in the book. Definitely I don't want to draw a venn diagram in GMAT :-) Thanks in advance.
tim
Course Students
 
Posts: 5665
Joined: Tue Sep 11, 2007 9:08 am
Location: Southwest Airlines, seat 21C
 

Re: Fastest way to calculate the GCF and LCM

by tim Thu Aug 23, 2012 2:57 am

you can't get around prime factoring each number. once you've gone to that trouble, drawing the circles around the prime factors to create a Venn Diagram is trivial. in other words, you won't be able to cut any further corners.. :)
Tim Sanders
Manhattan GMAT Instructor

Follow this link for some important tips to get the most out of your forum experience:
https://www.manhattanprep.com/gmat/forums/a-few-tips-t31405.html
andrew.weimholt
Forum Guests
 
Posts: 1
Joined: Tue Oct 02, 2012 9:49 am
 

Re: Fastest way to calculate the GCF and LCM

by andrew.weimholt Wed Oct 03, 2012 2:26 am

tim Wrote:you can't get around prime factoring each number. once you've gone to that trouble, drawing the circles around the prime factors to create a Venn Diagram is trivial. in other words, you won't be able to cut any further corners.. :)


NOT TRUE.
If G is the GCF of A and B, and A>B, then
A is congruent to k*G modulo B, where k is coprime to A and B.

This means we can find G as follows...

Suppose A=462 and B=632
632 mod 462 = 170 (so G must divide 170 and furthermore G=GCF(462,170))
462 mod 170 = 122 (so G must also divide 122, by now we can see it will be 2, but let's continue...)
170 mod 122 = 48
122 mod 48 = 26
48 mod 26 = 22
26 mod 22 = 4
22 mod 4 = 2
4 mod 2 = 0 (When we get to 0, the previous number is our G, so G=2).

Let's try again with 525 and 252...
525 mod 252 = 21
252 mod 21 = 0, therefore GCF(525,252) = 21

It can seem like more work than factoring, but for large numbers, it can be faster for a computer. Here is a recursive C function to find the gcf...

typedef unsigned long long u64;

u64 gcf(u64 a, u64 b)
{
u64 L = (a>b) ? a : b;
u64 S = (a>b) ? b : a;
u64 X = L%S;
return X ? gcf(X,S) : S;
}
tim
Course Students
 
Posts: 5665
Joined: Tue Sep 11, 2007 9:08 am
Location: Southwest Airlines, seat 21C
 

Re: Fastest way to calculate the GCF and LCM

by tim Thu Oct 04, 2012 8:58 am

Aditya, do you see now why i said you can't get around prime factoring if you want an "easy way" to do this one? As Andrew demonstrates, pretty much the only other way to do this problem is to use his Euclidean Algorithm approach, which as you can see definitely does not fit the bill of an "easy way" by any stretch of the imagination.. :)
Tim Sanders
Manhattan GMAT Instructor

Follow this link for some important tips to get the most out of your forum experience:
https://www.manhattanprep.com/gmat/forums/a-few-tips-t31405.html