Program to determine whether a given number is a Harshad numberExplanationIn this program, we need to determine whether given is Harshad or not. Harshad number A number is said to be the Harshad number if it is divisible by the sum of its digit. For example, if number is 156, then sum of its digit will be 1 + 5 + 6 = 12. Since 156 is divisible by 12. So, 156 is a Harshad number. Some of the other examples of Harshad number are 8, 54, 120, etc. To find whether the given number is a Harshad number or not, calculate the sum of the digit of the number then, check whether the given number is divisible by the sum of its digit. If yes, then given number is a Harshad number. Algorithm
SolutionPythonOutput: 156 is a harshad number COutput: 156 is a harshad number JAVAOutput: 156 is a harshad number C#Output: 156 is a harshad number PHPOutput: 156 is a harshad number
Next Topic#
|