Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-05-2005, 04:25 PM   #1 (permalink)
 
Newb Techie

Join Date: Mar 2005

Posts: 39

psyb0rg

Default Lcm

anyone know a way to find the LCM (Least Comman Factor) of two numbers?
psyb0rg is offline  
Old 04-05-2005, 11:42 PM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

Take a look at Euclidian's algorithm for this.

LCM = (n1 * n2) \ GCD(n1, n2)


I'm sniffin a homework assignment, so that's as far as I'm gonna go.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 04-06-2005, 10:39 AM   #3 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default

LCM = (n1 * n2) \ GCD(n1, n2)

In this expression n1*n2 ok. What will do " \ GCD(n1,n2)". What is mean by GCD ????????
Mohan Giri is offline  
Old 04-06-2005, 11:44 AM   #4 (permalink)
 
Newb Techie

Join Date: Mar 2005

Posts: 39

psyb0rg

Default

shouldn't it be in the form of numerators and denominators? and yes, what is GCD?
psyb0rg is offline  
Old 04-06-2005, 02:54 PM   #5 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

GCD is the greatest common divisor.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 04-06-2005, 03:14 PM   #6 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default

How to determine GCD?????
Mohan Giri is offline  
Old 04-07-2005, 03:01 PM   #7 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

This should be something that you can think about for a while and derive.

But I guess you guys want all the answers, here's the full code for deriving the least common multiple.

Code:
int GCD(int a, int b)
{
    int r;

    while(b)
        {
        r = a % b;
        a = b;
        b = r;
        }

    return(a);
}

int LCM(int a, int b)
{
    return a * b / GCD(a, b);
}

__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 04-08-2005, 08:04 AM   #8 (permalink)
 
Newb Techie

Join Date: Mar 2005

Posts: 39

psyb0rg

Default

Thanks a million!
psyb0rg is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On