Skip to content

Latest commit

 

History

History

harshad-number

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Harshad number

Problem link

Solutions

Solution.py

# https://leetcode.com/problems/harshad-number/

class Solution:
    def sumOfTheDigitsOfHarshadNumber(self, x: int) -> int:
        dsum = sum(int(d) for d in str(x))
        return dsum if x % dsum == 0 else -1

Tags