You are currently viewing the GMLscripts.com static mirror. Forum access and script submissions are not available through this mirror.

Invert GMLscripts.com

lcm

lcm(a,b)
Returns the least common multiple of the given integers.
COPY/// lcm(a,b)
//
//  Returns the least common multiple of the given integers.
//
//      a,b         non-negative integers, real
//
/// GMLscripts.com/license
{
    var a,b,c,r;
    a = max(argument0,argument1);
    b = min(argument0,argument1);
    c = a * b;
    while (b != 0) {
        r = a mod b;
        a = b;
        b = r;
    }
    return (c / a);
}

Contributors: xot

GitHub: View · Commits · Blame · Raw