
4. Find all 7-digit numbers formed by using only the digits 5 and 7 , and divisible by both 5 and 7 .


Solution: Clearly, the last digit must be 5 and we have to determine the remaining 6 digits. For divisibility by 7 , it is sufficient to consider the number obtained by replacing 7 by 0 ; for example 5775755 is divisible by 7 if and only 5005055 is divisible by 7 . Each such number is obtained by adding some of the numbers from the set $\{50,500,5000,50000,500000,5000000\}$ along with 5 . We look at the remainders of these when divided by 7 ; they are $\{1,3,2,6,4,5\}$. Thus it is sufficient to check for those combinations of
remainders which add up to a number of the from $2+7 k$, since the last digit is already 5 . These are $\{2\},\{3,6\},\{4,5\},\{2,3,4\},\{1,3,5\},\{1,2,6\}$, $\{2,3,5,6\},\{1,4,5,6\}$ and $\{1,2,3,4,6\}$. These correspond to the numbers $7775775,7757575,5577775,7575575,5777555,7755755,5755575,5557755$, 755555 .
