Counting magic numbers

This is the revised version of the problem. Resubmit your work here.

Given two integers N and K, such that N>0 and N>K, count those numbers from the range of 1 to N whose sums of digits are divisible by K.

If the numbers are out of the given range "Wrong input" is displayed.

Input
100 3

Output
33
Note: just recall that an integer is divisible by 3 if the sum of its digits is divisible by 3.


Input
22 4

Output
5
Note: Numbers from 1 to 22 whose sums of digits are divisible by 4 are: 4, 8, 13, 17, and 22.




CAN SOMEONE HELP ME WITH THIS ?
All that I wrote in your first thread http://www.cplusplus.com/forum/general/234595/
applies here too.


I would make a helper function for the "sum of digits", because it is a clear subtask.
Topic archived. No new replies allowed.