Ooh, that's neat ... from what you posted, this is what I got.
We're looking for a number N that is divisible by x, and whose digits sum to y.
First, you consider all the divisors of y (by getting the prime factorization of y. Any combination of the prime factors will divide y).
Second, since N is divisible by x, it is a multiple of x. So, we consider some multiples of x, and we check the sum of their digits. We are looking for those multiples of x whose digits sum up to a divisor of y.
Say we find such a number U, and the sum of it's digits is V (and V is also a divisor of y). Then N is simply U written times.
For example, with x=y=2002
The divisors of 2002 are:
We consider some multiples of 2002 and the sum of their digits:
10010 2 *Opalg's example
14 divides 2002, and . So, we just have to write 16016 143 times (16016160161601616016..........1601616016). That's another number that's divisible by 2002 and whose digits sum to 2002. Also, since , I believe dividing this number (1601616016...) by 8 will yield a number 143 digits long with 8 for all it's digits (i.e. 888888...8888 where 8 is written 143 times).
Some interesting things to think about are:
1A) if there is a case in which no multiple of x has digits that sum up to a divisor of y.
1B) If the above case exist, does it necessarily mean that there does not exist a number N that satisfies the condition? (Look at number 3 below)
2) if x=y, will there always exist a number N?
3) The method we used takes advantage of repeating the number, but what about cases with non-repeating numbers?