Python program to check if a number is Harshad number
What is a Harshad number
A number is said to be Harshad if, the number formed by the sum of digits is a factor of the given number.
Example
54 is a Harshad number
5+4 = 9
9 is a factor of 54
Python program to check if a number is Harshad
n = int(input())
# Store it in a temp variable
t=n
# variable to Store sum of digits
s=0
while n>0:
r = n%10
s += r
n //= 10
# if number is divisible with the sum
if t%s==0:
print("Harshad")
else:
print("Not Harshad")