New Reply

Least Common Multiple

 
Share Thread Thread Tools
Jan6-13, 03:40 AM   #1
 

Least Common Multiple


I'm reading this programming code that basically says if 1 of 2 variables (x and y) is less than 0, then their least common multiple is 0.




If we have x=-2 and y=+3, then their least common multiple is 0.

I don't get it. I know what a least common multiple is, but this one isn't very intuitive to me.

Can someone explain?
 
PhysOrg.com
PhysOrg
mathematics news on PhysOrg.com

>> Mathematicians analyze social divisions using cell phone data
>> Can math models of gaming strategies be used to detect terrorism networks?
>> Mathematician proves there are infinitely many pairs of prime numbers less than 70 million units apart
Jan6-13, 03:48 AM   #2
 
Recognitions:
Homework Helper Homework Help
That is not the usual definition. Usually lcm(-2,3)=6 and
lcm(a,b)=|ab|/gcd(a,b)
 
Jan6-13, 04:37 AM   #3
 
Blog Entries: 8
Recognitions:
Gold Membership Gold Member
Science Advisor Science Advisor
Retired Staff Staff Emeritus
Quote by pyroknife View Post
I'm reading this programming code that basically says if 1 of 2 variables (x and y) is less than 0, then their least common multiple is 0.




If we have x=-2 and y=+3, then their least common multiple is 0.

I don't get it. I know what a least common multiple is, but this one isn't very intuitive to me.

Can someone explain?
Well, it's just a definition. It's not the usual definition and it's probably not a very useful one either. So there is no explanation other that the authors of the code implemented things like this.
 
Jan6-13, 05:59 PM   #4
 

Least Common Multiple


Part of the code written in C is:
if ( u < 0 || v < 0 )
return 0;

The overall code asks to find the lcm of u and v. If u or v is <0, then lcm of u and v is 0.
 
Jan6-13, 06:42 PM   #5
 
Recognitions:
Homework Helper Homework Help
Science Advisor Science Advisor
Looks like the author considered it an error case and used a result of zero to signal an error condition back to the caller. This ought to be part of the declared interface. (But what does it return if an operand is 0?)
If negative values are valid in your case, just wrap the operands in abs().
 
New Reply
Thread Tools


Similar Threads for: Least Common Multiple
Thread Forum Replies
Highest Common Factor and Lowest Common Multiple Precalculus Mathematics Homework 2
Finding Common period of multiple waveforms General Math 3
common emitter vs. common collector power amplification Electrical Engineering 3
Least common multiple of the orders of the elements in a finite Abelian group Calculus & Beyond Homework 4
hard? least common multiple problem General Math 3