<s>[INST] How many 20-digit numbers are there which are formed using only the digits 5 and 7 and divisible by both 5 and 7. now i realised last digit has to be $5$ and position of $7$ wont affect divisibility.
$$x_{1}x_{2}x_{3}x_{4}x_{5}x_{6}x_{7}x_{8}x_{9}x_{10}x_{11}x_{12}x_{13}x_{14}x_{15}x_{16}x_{17}x_{18}x_{19}x_{20}\equiv 0 \mod 7$$
so $x_{i}$ will be $1$ if it is $5$ and $0$ if it is $7$,so $x_{20}$=1.and then by remainder of powers of 10 i have to decide in which position $5$'s have to be placed.
so now its basically a combinatorics problem which i am unable to solve. please help.
 [/INST] The question boils down to the following: How many $x_i \in \{ 5,7 \}$ can you find such that 
$$x_1...x_{19}5 \equiv 0 \pmod{7}$$
Since $7$ is divisible by $7$, we can replace all $7's$ by $0$s.
Define $y_i =1$ if $x_i=5$ and $0$ otherwise. So the problem boils to 
$$5\cdot y_1...y_{19}1 \equiv 0 \pmod{7}$$
or
$$  y_1...y_{19}1 \equiv 0 \pmod{7} \,.$$
As the powers of $10 pmod {7}$ are cyclically $1, 3, 2, 6, 4, 5$, the problem becomes
$$(1+y_{14}+y_{8}+y_{2})+3 (y_{19}+y_{13}+y_{7}+y_{1}) + 2 (y_{18}+y_{12}+y_{6})+6(y_{17}+y_{11}+y_{5})+4(y_{16}+y_{10}+y_{5})+5(y_{15}+y_{9}+y_{3}) \equiv 0 \pmod{7}$$
Define 
$$a= 1+y_{14}+y_{8}+y_{2} \\
b=y_{19}+y_{13}+y_{7}+y_{1} \\
c=y_{18}+y_{12}+y_{6} \\
d= y_{17}+y_{11}+y_{5} \\
e=y_{16}+y_{10}+y_{5} \\
f= y_{15}+y_{9}+y_{3} (*)$$
Then the problem reduces to the following  simpler problems:
Problem: Find all solutions of 
$$a+3b+2c+6d+4e+5f =0 \pmod{7}$$
with $1 \leq a \leq 4 \,;\, 0 \leq b \leq 4 \,;\, 0 \leq c,d,e,f \leq 3$.
Now for each solution, when you look back at $(*)$ you have to figure out how many ways can you distribute the 1's among the y's. The problem becomes the problem of choosing in order $a-1, b, c, d,  e, f$ positions for ones out of $3,4,3,3,3,3$, so the final answer will be
$$\sum_{(a,b,c,d,e,f) \mbox{solution} } \binom{3}{a-1} \binom{4}{b} \binom{3}{c}\binom{3}{d}\binom{3}{e}\binom{3}{f}$$
</s>