Skip to main content
OlympiadHQ

Browse · MathNet

Print

VMO

Vietnam counting and probability

Problem

Given a positive integer . Find the number of non-negative integers that do not exceed and satisfy the following conditions

i) is divisible by , ii) The digits of in decimal representation are in the set .
Solution
Denote by and Let and be the cardinal number of , and respectively. Since a natural number is divisible by if and only if the sum of its digits is a multiple of , we only need to count the number of elements in the set . Let be an element of , we have

If then . If or then . If then .

Hence, (1). Similarly, we get From those equations, we have , , , , , . Moreover, This leads to Similarly, Hence, it is easy to see that
If then . If then . If then .

On the other hand, is equal to the cardinal number of so that In conclusion, the value of is if is not a multiple of ; if is a multiple of .
Final answer
If k is a multiple of three: (4^k + 2) / 3; otherwise: (4^k − 1) / 3.

Techniques

Recursion, bijectionModular ArithmeticRecurrence relations