Let $N$ be a group. Assume that $N$ is torsion-free, finitely generated and nilpotent. I read somewhere that
$$ Z(N) \subset [N,N] \iff N \text{ cannot be written as a direct product of groups } N = A \times B \text{ where }A \text{ is non-trivial abelian.}$$
One implication is clear to me: $\implies$. I prove it by contraposition: assume $N$ can be decomposed as $A\times B$ where $A$ is non-trivial abelian. Then it is clear that $$ Z(N) = Z(A) \times Z(B) = A\times Z(B).$$
On the other hand, we have that
$$ [N,N] = [A,A] \times [B,B] = \{1\} \times [B,B].$$
If we had that $Z(N) \subset [N,N]$, we would need that $A\subset \{1\}$, which is clearly not possible as $A$ was non-trivial. So by contraposition, we have proven the first implication.
Now my problem is with the other implication. I don't know how I can prove the converse. I don't even know how to go about doing that. My gut suggests contraposition again, but then I have to use the assumption that $Z(N) \not\subset [N,N]$ to somehow construct a direct product decomposition of $N$ which has a non-trivial abelian factor, and I don't see how I can go about doing something like that.
Does anyone have any suggestions?
Thanks in advance!
Edit: I added the assumptions that $N$ is torsion-free, finitely generated and nilpotent. These are the only groups I am interested in in the context of my research.