**Harshad Number**

A number is said to be harshad number , If it is divisible by the sum of its digit.

**For example- **

Let number be 18

Sum of digit of 18 id 1 + 8 = 9

Hence, 18 is divisible by 9 , therefore 18 is harshad number.

Some of the example of harshad number are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80, 81, 84, 90, 100, 102, 108, 110, 111, 112, 114, 117, 120, 126, 132, 133, 135, 140, 144, 150, 152, 153, 156, 162, 171, 180, 190, 192, 195, 198, 200, ...

**Algorithm to find whether the given number is Harshad number or not.**

- Declare and initialize value for remainder = 0 , sum = 0, n, num .
- Now take user input as a integer for variable num.
- Copy the value of variable num into n.
- Now check if num is greater than 0, then calculate the remainder by dividing it with 10
- Add that remainder to the sum.
- Now Divide num by 10.
- Repeat the step from 3 to 5 , till num become less than 0.
- Atlast divide n with sum, if remainder is 0, then it is harshad number, else the user input is not a harshad number.

Input

Output

# | Program | Language |
---|---|---|

1 | Java | |

2 | Java | |

3 | Java | |

4 | Java | |

5 | Java | |

6 | Java | |

7 | Java | |

8 | Java | |

9 | Java | |

10 | Java | |

11 | Java | |

12 | Java | |

13 | Java | |

14 | Java | |

15 | Java | |

16 | Java | |

17 | Java | |

18 | Java | |

19 | Java | |

20 | Java | |

# | Program | Language |

Copyright © 2020 Inovatik - All rights reserved