# Finding every triplet $(n,a,b)$ such that $n!=2^a-2^b$

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?

• I would strongly suspect that there are only finitely many solutions, but unless there is some trick it is likely to be really hard to prove. We can always find $n$ so that $2^n-1$ has any particular odd factor we want. The difficulty is that it will also have factors we do not want. – almagest Sep 4 '14 at 10:32
• @almagest: I agree with you and that's exaclty what I've thought about:) – mathlove Sep 4 '14 at 10:35
• Information on the integer sequence described [here][1] may shed light on this problem. [1]: oeis.org/… – MartinG Sep 4 '14 at 11:58

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.
• Could you elaborate the part that "An elementary argument shows that necessarily $a-b$ is a multiple of $2 \cdot 3^{k-1}$"? – mathlove Sep 6 '14 at 10:21
• $2$ is a primitive root modulo $9$ and hence modulo $3^k$ for all $k$. – Mike Bennett Sep 6 '14 at 14:55
• "$2$ is a primitive root modulo $9$ and hence modulo $3^k$ for all $k$." This is true, but it doesn't extend that easily to all powers of $3$. One has to check whether $9\mid2^{3-1}-1$, luckily this is not the case. – punctured dusk Sep 8 '14 at 7:40
• Ummm, if $r$ is a primitive root mod $p^2$, then $r$ is a primitive root mod $p^k$ for all $k$. Luck is not involved… – Mike Bennett Sep 9 '14 at 19:37