fix: handle zeros in CoPrimeCheck (#1622)

This commit is contained in:
Piotr Idzik
2024-02-29 06:06:08 +01:00
committed by GitHub
parent a5945e37c2
commit 8734dfccf9
2 changed files with 8 additions and 15 deletions

View File

@@ -8,7 +8,9 @@ describe('CoPrimeCheck', () => {
[1, 7],
[20, 21],
[5, 7],
[-5, -7]
[-5, -7],
[1, 0],
[-1, 0]
])('returns true for %j and %i', (inputA, inputB) => {
expect(CoPrimeCheck(inputA, inputB)).toBe(true)
expect(CoPrimeCheck(inputB, inputA)).toBe(true)
@@ -16,7 +18,9 @@ describe('CoPrimeCheck', () => {
it.each([
[5, 15],
[13 * 17 * 19, 17 * 23 * 29]
[13 * 17 * 19, 17 * 23 * 29],
[2, 0],
[0, 0]
])('returns false for %j and %i', (inputA, inputB) => {
expect(CoPrimeCheck(inputA, inputB)).toBe(false)
expect(CoPrimeCheck(inputB, inputA)).toBe(false)