TITLE: Finding every triplet $(n,a,b)$ such that $n!=2^a-2^b$
QUESTION [6 upvotes]: Question : Let $n,a,b$ be positive integers. Are there infinitely many triplets $(n,a,b)$ which satisfy the following equality?$$n!=2^a-2^b$$
  If Yes, then how can we prove that? If No, then how can we find every such triplet $(n,a,b)$? 

The followings are what I've got : 
$(1)$ We can get $(n,a,b)=(2,2,1),(3,3,1),(4,5,3),(5,7,3)$ easily.
$(2)$ $a$ can be represented by $n$ :
Let $2^{A_n}$ be the least number in the form of $2^i$ larger than $n!$, namely
$$2^{A_n-1}\le n!\lt 2^{A_n}\iff A_n-1\le \log_2{n!}\lt A_n\iff A_n=\lfloor \log_2{n!}\rfloor+1$$
where $\lfloor x\rfloor $ represents the largest integer not greater than $x$.
Supposing $a\gt A_n$ gives us
$$n!=2^a-2^b\ge 2^{A_n+1}-2^{A_n}=2^{A_n}\gt n!.$$ 
This is a contradiction. Hence, we have $a=A_n=\lfloor \log_2{n!}\rfloor+1$.
$(3)$ $b$ can be represented by $n$ :
We have $n!=2^b(2^{a-b}-1).$ Since $2^b$ is even and $2^{a-b}-1$ is odd, we know that $b$ is the number of $2$ as a prime factor of $n!$, namely
$$b=\sum_{k=1}^{\lfloor \log_2 n\rfloor}\left\lfloor\frac{n}{2^k}\right\rfloor.$$
$(4)$ From $(2),(3)$, the question can be represented as the following :

Question : Are there infinitely many positive integer $n$ which satisfy the following equality?
  $$n!=2^{\lfloor \log_2{n!}\rfloor+1}-2^{\sum_{k=1}^{\lfloor \log_2 n\rfloor}\left\lfloor\frac{n}{2^k}\right\rfloor}$$
  If Yes, then how can we prove that? If No, then how can we find every such $n$? 

$(5)$ It seems that $n\ge6$ don't satisfy the equation in $(4)$ using computer.
Can anyone help?

REPLY [3 votes]: Begin by noting that, if $n \geq 9$, then $3^k \mid n!$ where $k > n/3$. It follows that, if we have
$$
n! = 2^a - 2^b
$$
with $n \geq 9$, then 
$$
2^{a-b} \equiv 1 \mod{3^k}
$$
for some $k > n/3$. An elementary argument shows that necessarily $a-b$ is a multiple of $2 \cdot 3^{k-1}$ and, in particular, that
$$
a-b \geq 2 \cdot 3^{k-1} > 2 \cdot 3^{n/3-1}.
$$
Since $n! \geq 2^{a-1}$, we thus have that
$$
\log (n!) > 2 \cdot 3^{n/3-1} \log (2).
$$
On the other hand, from Stirling's formula,
$$
\log (n!) < 1-n+(n+1/2) \log n
$$
and hence
$$
2 \cdot 3^{n/3-1} \log (2) < 1-n+(n+1/2) \log n.
$$
A short computation shows that this is a contradiction for $n \geq 10$. Checking the smaller values gives the solutions noted by the OP.