15,748,330 members
1.00/5 (1 vote)
See more:
`In a far away Galaxy of Milky Way, there was a planet Tarth where the sport of Competitive Tiding 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 math's 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=0 NmodK=0, where KK denotes the sum of digits of NN. That is, NN should be divisible by the sum of its digits.`
```Input
The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
The first and only line of each test case contains one integer NN.
Output
For each test case, print a single line containing "Yes" or "No".```

What I have tried:

yes but it gives the wrong answer
```Example Input
5
10
13
75
55640877376
3622056459435540
Example Output
Yes
No
No
Yes
Yes
Explanation
Example case 1: (10mod(1+0))=(10mod1)=0(10mod(1+0))=(10mod1)=0

Example case 2: (13mod(1+3))=(13mod4)=1(13mod(1+3))=(13mod4)=1
Hence it is not a harshad number.

Example case 3: (75mod(7+5))=(75mod12)=3(75mod(7+5))=(75mod12)=3
Hence it is not a harshad number.```
Posted
Updated 13-Apr-22 21:00pm
Patrice T 14-Apr-22 2:47am
And the problem or question is ?

## Solution 1

Compute the sum of the number digits (the `%` operator can be useful. For instance, `(N % 10)` gives the units of `N`) then check the divisibility.
Doesn't look a daunting task to me.