# compute-lcm **Repository Path**: ArkTSCentralRepository/compute-lcm ## Basic Information - **Project Name**: compute-lcm - **Description**: Computes the least common multiple (lcm). - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-25 - **Last Updated**: 2026-03-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # compute-lcm 基于[compute-lcm](https://www.npmjs.com/package/compute-lcm)原库1.1.2版本进行适配 ## Install ```sh ohpm install compute-lcm ``` ## Usage > Computes the [least common multiple](http://en.wikipedia.org/wiki/Least_common_multiple) (lcm). __Note__: the lcm is also known as the __lowest common multiple__ or __smallest common multiple__ and finds common use in calculating the __lowest common denominator__ (lcd). ``` typescript import lcm from 'compute-lcm'; ``` #### lcm( a, b[, c,...,n] ) Computes the [least common multiple](http://en.wikipedia.org/wiki/Least_common_multiple) (lcm) of two or more `integers`. ``` javascript let val = lcm( 21, 6 ); // returns 42 let val = lcm( 21, 6, 126 ); // returns 126 ``` #### lcm( arr[, clbk] ) Computes the [least common multiple](http://en.wikipedia.org/wiki/Least_common_multiple) (lcm) of two or more `integers`. ``` javascript let val = lcm( [21, 6] ); // returns 42 let val = lcm( [21, 6, 126] ); // returns 126 ``` For object `arrays`, provide an accessor `function` for accessing `array` values. ``` javascript const data = [ ['beep', 4], ['boop', 8], ['bap', 12], ['baz', 16] ]; const getValue = (d: (string | number)[], i: number) => { return d[1]; }; let val = lcm( data, getValue ); // returns 48 ``` ## Notes - If provided a single `integer` argument or an `array` with a length less than `2`, the function returns `null`.