File tree 2 files changed +9
-1
lines changed
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- Problem statement and Explanation : https://en.wikipedia.org/wiki/Greatest_common_divisor
2
+ Problem statement and Explanation : https://en.wikipedia.org/wiki/Euclidean_algorithm
3
3
4
4
In this method, we have followed the iterative approach to first
5
5
find a minimum of both numbers and go to the next step.
12
12
* @returns return a `gcd` value of both number.
13
13
*/
14
14
const getGcd = ( arg1 , arg2 ) => {
15
+ // firstly, check that input is a number or not.
16
+ if ( typeof arg1 !== 'number' || typeof arg2 !== 'number' ) {
17
+ return new TypeError ( 'Argument is not a number.' )
18
+ }
15
19
// Find a minimum of both numbers.
16
20
let less = arg1 > arg2 ? arg2 : arg1
17
21
// Iterate the number and find the gcd of the number using the above explanation.
Original file line number Diff line number Diff line change 8
8
* @returns `Number` n reverse in reverse.
9
9
*/
10
10
const ReverseNumber = ( number ) => {
11
+ // firstly, check that input is a number or not.
12
+ if ( typeof number !== 'number' ) {
13
+ return new TypeError ( 'Argument is not a number.' )
14
+ }
11
15
// A variable for storing the reversed number.
12
16
let reverseNumber = 0
13
17
// Iterate the process until getting the number is 0.
You can’t perform that action at this time.
0 commit comments