2025-08-22 16:43:35 +0000 UTC
Harshad Number
Categories:
Links
Code
class Solution:
def sumOfTheDigitsOfHarshadNumber(self, x: int) -> int:
cur = x
sm = 0
while cur > 0:
sm += cur % 10
cur //= 10
if x % sm == 0:
return sm
return -1