In GAP, How can I check whether a given group is a direct product? I'm working with GAP and I want to make some check through all small group up to given size. For direct product groups the result is depend on the groups it composed of, so I don't want to waste time on such groups. Is there a built-in option to check whether a group is a (not trivial) direct product?
 A: There is the command StructureDescription(G) which gives a name for the group $G$ and could tell you whether $G$ is a direct product or not. However, it just gives you a string and not the subgroups giving the decomposition.
But in the algorithm of StructureDescription (described here) a decomposition is found at some point. According to the answer given by Alexander Konovalov here, the command StructureDescription uses the undocumented method DirectFactorsOfGroup to do this.
So you can use
DirectFactorsOfGroup(G);

which returns a list $[G_1, \ldots, G_n]$ such that $G = G_1 \times \cdots \times G_n$. I suppose this will always return $G_i$ which are directly indecomposable, since the algorithm of StructureDescription states that we "Decompose G into a direct product of irreducible factors.".
A: The question would be more interesting if you asked how you might do this rather than asking whether there is a command to do it in GAP. 
Here is a first suggestion, which you could easily implements in GAP. There might be better ways.
Start by finding all nontrivial proper normal subgroups of $G$. For each such subgroup $N$ compute its centralizer $C_G(N)$ in $G$. If $NC_G(N) = G$, then check among your list of normal subgroups to see if any of them lie in $C_G(N)$ and complement $N$.
The first step would be a bit silly if for example $G$ was a large elementary abelian group, so you might want to start by checking if the group is abelian, in which case it is a direct product iff it is not cyclic of prime power order.
I am sure there other situations in which finding all normal subgroups would be a bad idea because there are too many of them, such as extraspecial $p$-groups, which are not direct products, so I am only suggesting this as a first attempt.
