Explore
ProGrad Programs
About Us

Edit
Reply




Edit

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

Published on 10 Mar 2020

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.


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


Algorithm to check whether a number is 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


C
C++
Java
Python 3

Output
1729
Harshad Number


´╗┐Recommended Programs










If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in