Harshad numbers

Write codeHard35 min

Your task

Count how many integers in the inclusive range [1, n] are divisible by their own digit sum (Harshad / Niven numbers). For example 12 qualifies because 12 is divisible by 1+2=3. Constraints: 1 <= n <= 200000. Return the count.

Examples

count_harshad(n: int) -> int
Example 1
Inputcount_harshad(12)
Output11