The answer is 18144.

**
This section requires Javascript.
**

You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.

The largest is

$a=7.\lfloor \frac{10^{2017}}{7} \rfloor$

note that

$10^{2017}=7\times t+3 \implies t=\frac{10^{2017}-3}{7} \implies a=7 \times t=10^{2017}-3$

$a$ has 2016 $9$ 's and 1 $7$ , so the sum of its digits is $A=9.2016+7$

Similarly, the smallest is

$b=7.(\lfloor \frac{10^{2016}}{7}+1) \rfloor$

and

$10^{2016}=7\times k+1 \implies k=\frac{10^{2016}-1}{7} \implies b=7 \times (k+1)=10^{2016}-1+7=10^{2016}+6$

$b$ has 2015 $0$ 's, 1 $1$ and 1 $6$ , so the sum of its digits is $B=1+6$

Finally $A-B=2016 \times 9$