How to Check IF a Number is Harshad or Niven Number in Python |EP-31 Harshad/Niven Number in Python
"""Harshad Numbers can be divided by the sum of its digits. They are also called
Niven Numbers. For instance, 18 is a Harshad Number as it can be divided by 9, the sum of
its digits (8+1=9)"""
Num = input("enter the number:")
print(num)
num = int(num)
digit_1 = num[0:1]
print(digit_1)
digit_2 = num[1:]
print(digit_2)
sum = int(digit_1)+int(digit_2)
print(sum)
if num%sum==0:
print("given number is harshad/niven number")
else:
print("not harshad/navin number")
#PythonProgramming #HarshadNumber #NivenNumber #PythonTutorial #CodingForBeginners #LearnPython #PythonNumbers #ProgrammingBasics #TechTonic #PythonCode #PythonExamples #HarshadNumbers #NivenNumbers #CodingTutorial #PythonCode #Programming #Coding #Tech #Education #Tutorial
Connect With Us:
—————————————
➡️ Website: https://www.cybrosys.com/
➡️ Email: info@cybrosys.com
➡️ Twitter: / cybrosys
➡️ LinkedIn: / cybrosys
➡️ Facebook: / cybrosystechnologies
➡️ Instagram: / cybrosystech
➡️ Pinterest: / cybrosys