Check whether a number is Harshad number or not (Niven number) | faceprep

Check whether a number is Harshad number or not (Niven number) | faceprep

A program to check whether a number is a Harshad number or not (Niven number) is discussed here. Harshad Number is an integer that is divisible by the sum of its digits.

check whether a number is harshad number or not


Input format:

  • Input consists of 1 integer.
  • If the given number is Harshad Number display Harshad Number or display Not Harshad Number.

Sample Input:

1729

Sample Output:

Harshad Number


face prep pro ad banner Click here to learn more about FACE Prep PRO


Algorithm to check whether a number is a Harshad number or not

  • Get the input from the user
  • Find the sum of its digits.
  • If the number is divisible by the sum of its digits, print “Harshad Number”.
  • Else, display “Not Harshad Number”.

Program to check whether a number is a Harshad number or not

@@coding::1@@


Recommended Programs


Check whether a number is Harshad number or not (Niven number)

c