Lowest common multiple and greatest common divisor

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
User avatar
Irrlicht
Dragon
Posts: 426
Joined: Mon Feb 09, 2009 10:53 am

Lowest common multiple and greatest common divisor

Post by Irrlicht »

I see there aren't built-in functions for this, so what would you advise to make macros where you can calculate lowest common multiple and greatest common divisor from lists of numbers (possibly with virtually unlimited lists... within reason, of course... I know throwing in a list of a thousand numbers could be taxing... and probably will never have lists longer than ten numbers).
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Lowest common multiple and greatest common divisor

Post by aliasmask »

You mean like factors? So, for 10 it would be 2,5 and 20 would be 2,2,5?

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Lowest common multiple and greatest common divisor

Post by wolph42 »

multiples of 4: 4,8,12,16,20,24, etc
multiples of 6: 6,12,18,24,etc

Hence the 'common multiples' are: 12,24,36,etc

So the LCM (lowest common multiple) of 4 and 6 is 12

divisors of 4: 1,2,4 (aka factors as AM mentioned)
divisors of 6: 1,2,3,6

'common divisors': 1,2

So the GCD (greatest common divisor) of 4 and 6 is 2.

My Q is: what on earth do you require this for in MT?

Post Reply

Return to “Macros”