HNUM: Joy giving number


Problem Link:

Problem: HNUM

In a far away Galaxy of Tilky Way, there was a planet Tarth where the sport of Tompetitive Toding was very popular. According to legends, there came a new setter who loved maths. Hence, he made TCDSAP (Todechef Certified Data Structure & Algorithm Programme) with questions involving maths problems.

Given a positive number NN, you have to find if NN is a Harshad number or not.
A number NN is called a “Harshad number” if and only if NmodK=0NmodK=0, where KK denotes the sum of digits of NN. That is, NN should be divisible by the sum of its digits.


#include <iostream>
using namespace std;
#define ll long long

int main() {
  int t;
      ll n;
      ll nn= n;
      int sum= 0;
          sum+= nn%10;
      if(n%sum) cout<<"No\n";
      else cout<<"Yes\n";
  return 0;