Skip to content

compute lcm

kgryte edited this page May 12, 2015 · 1 revision

Computes the least common multiple (lcm) of two or more integers.

var val = compute.lcm( [21, 6] );
// returns 42

For object arrays, provide an accessor function for accessing array values

var data = [
	{'x':8},
	{'x':12},
	{'x':16}
];

function getValue( d, i ) {
	return d.x;
}

var val = compute.lcm( data, getValue );
// returns 48

If provided an array with a length less than 2, the method returns null.

Note: the method also provides a variadic interface. See compute-lcm for additional details.

Clone this wiki locally