Learn Programming
Learning new Things
Harshad number In Python
Harshad number In Python
Harshad Number is an integer that is divisible by the sum of its digits.
Program:
n = int(input("Enter Number"))
sum = 0
temp = n
while(temp > 0):
sum += temp % 10
temp = int(temp // 10)
res = n % sum
if(res == 0):
print("Harshad Number");
else:
print("Not Harshad Number");
OutPut:
Enter Number1729
Harshad Number
Enter Number1930
Not Harshad Number
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment