mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
fix number checking
This commit is contained in:
@ -20,6 +20,10 @@ const GetEuclidGCD = require('./GetEuclidGCD')
|
|||||||
* @returns return correspond boolean value, if both number are co-prime return `true`, else return `false`.
|
* @returns return correspond boolean value, if both number are co-prime return `true`, else return `false`.
|
||||||
*/
|
*/
|
||||||
const CoPrimeCheck = (firstNumber, secondNumber) => {
|
const CoPrimeCheck = (firstNumber, secondNumber) => {
|
||||||
|
// firstly, check that input is a number or not.
|
||||||
|
if (typeof firstNumber !== 'number' || typeof secondNumber !== 'number') {
|
||||||
|
return new TypeError('Argument is not a number.');
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
This is the most efficient algorithm for checking co-primes
|
This is the most efficient algorithm for checking co-primes
|
||||||
if the GCD of both the numbers is 1 that means they are co-primes.
|
if the GCD of both the numbers is 1 that means they are co-primes.
|
||||||
|
Reference in New Issue
Block a user