GAP:IsDirectFactor

Function type
The function takes as input two arguments, both of which are groups living inside a common parent group, and outputs a boolean (true/false).

Behavior
The function behaves as follows:


 * If the two groups are subgroups of a common parent group, and the second group is not a subgroup of the first, the function returns false.
 * If the two groups are subgroups of a common parent group, and the second group is a direct factor of the first, the function returns false.
 * If the two groups are subgroups of a common parent group, and the second group is a subgroup of the first but not a direct factor, the function returns true.
 * If the two groups do not live as subgroups of a common parent group, GAP returns a NoMethodFound error.

Typical use
The typical use is as follows:

IsDirectFactor(group,subgroup);

Code
IsDirectFactor := function(G,H) return (IsSubgroup(G,H) and IsNormal(G,H) and ForAny(NormalSubgroups(G),L -> Order(L) * Order(H) = Order(G) and IsTrivial(Intersection(H,L)))); end;;