feat(gcd,lcm): Allow arbitrarily many arguments

And add an 'associate' predicate for two complex numbers to check the results
This commit is contained in:
Glen Whitney 2022-08-02 10:32:06 -07:00
parent 1b8314c0cc
commit 880efac15b
5 changed files with 31 additions and 0 deletions

View file

@ -103,4 +103,13 @@ describe('The default full pocomath instance "math"', () => {
assert.strictEqual(math.choose(21n, 2n), 210n)
})
it('calculates multi-way gcds and lcms', () => {
assert.strictEqual(math.gcd(30,105,42), 3)
assert.ok(
math.associate(
math.lcm(
math.complex(2n,1n), math.complex(1n,1n), math.complex(0n,1n)),
math.complex(1n,3n)))
})
})