File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 11/*
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
33
44 In this method, we have followed the iterative approach to first
55 find a minimum of both numbers and go to the next step.
1212 * @returns return a `gcd` value of both number.
1313 */
1414const 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+ }
1519 // Find a minimum of both numbers.
1620 let less = arg1 > arg2 ? arg2 : arg1
1721 // Iterate the number and find the gcd of the number using the above explanation.
Original file line number Diff line number Diff line change 88 * @returns `Number` n reverse in reverse.
99 */
1010const 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+ }
1115 // A variable for storing the reversed number.
1216 let reverseNumber = 0
1317 // Iterate the process until getting the number is 0.
You can’t perform that action at this time.
0 commit comments