Skip to content

Commit 548fe75

Browse files
committed
chore: update argument values
1 parent 9fa5a04 commit 548fe75

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Maths/IsHarshad.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
* A Harshad number (or Niven number) is a positive integer that is divisible by the sum of its own digits.
44
*
55
* The function checks if a number is a Harshad (Niven) number.
6-
* @param {any} n - The number to check
6+
* @param {any} val - The number to check
77
* @returns {boolean} - true if Harshad, false otherwise
88
* @example isHarshad(2025) // true
99
*/
10-
export const isHarshad = (n) => {
11-
const num = Number(n)
10+
export const isHarshad = (val) => {
11+
const num = Number(val)
1212

1313
if (num <= 0 || !Number.isInteger(num)) return false
1414

1515
let sum = 0,
16-
temp = n
16+
temp = num
1717

1818
while (temp > 0) {
1919
sum += temp % 10
2020
temp = Math.floor(temp / 10)
2121
}
2222

23-
return n % sum === 0
23+
return num % sum === 0
2424
}

0 commit comments

Comments
 (0)