# HNUM: Joy giving number

**Problem Link: https://www.codechef.com/CU1AP0004**

**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.

**Solution:**

```
#include <iostream>
using namespace std;
#define ll long long
int main() {
int t;
cin>>t;
while(t--){
ll n;
cin>>n;
ll nn= n;
int sum= 0;
while(nn>0){
sum+= nn%10;
nn/=10;
}
if(n%sum) cout<<"No\n";
else cout<<"Yes\n";
}
return 0;
}
```

The content uploaded on this website is for reference purposes only. Please do it yourself first. |