Home >>Python Programs >Python program to determine whether the given number is a Harshad Number.
In this example, we will see a Python program through which we can determine whether the given number is a Harshad number or not.
Any given number is known as a Harshad Number if that number is divisible by the sum of its digits.
num = 156;
rem = sum = 0;
#Make a copy of num and store it in variable n
n = num;
#Calculates sum of digits
while(num > 0):
rem = num%10;
sum = sum + rem;
num = num//10;
#Checks whether the number is divisible by the sum of digits
if(n%sum == 0):
print(str(n) + " is a harshad number");
else:
print(str(n) + " is not a harshad number");