Spoiler:

if and only if is not of the form .

Proof:

Using as the double factorial of :

and therefore if and only if , where satisfies (that is, , but ).

We'll use the fact that ( prime) (Legendre's formula). The exponent of in is:

Where the equality signs of are taken if and only if is a power of two. Thus, if and only if is not a power of , and so if and only if is not of the form .

Q.E.D