Computing the length of a finite group Can someone suggest a GAP or MAGMA command (or code) to obtain the length $l(G)$ of a finite group $G$, i.e. the maximum length of a strictly descending chain of subgroups in $G$?
Thanks in advance.

I believe the length of the simple groups are not known in general, so this will require the groups involved to be small enough to do some brute force calculations.
Assuming the length is an invariant of the composition factors, we try an inductive approach for simple groups: l(G) = max( l(M) : M a maximal subgroup of G ) + 1.  For composite groups, we just add up the lengths on the composition factors.
Since magma has large precomputed tables of maximal subgroups of groups (that have had errors), I recommend it for speed. 
subgroupLength := function( grp )
  len := $$;
  if #grp eq 1 then return 0;
  elif IsSolvable( grp ) then return &+[ pn[2] : pn in FactoredOrder( grp ) ];
  elif IsSimple(grp) then return 1 + Max( { len( max`subgroup ) : max in MaximalSubgroups( grp) } );
  // else return &+[ len( groupForm( cf ) ) : cf in CompositionFactors( grp ) ];
  else // use the series 1 < O_oo(O^oo(G)) < O^oo(G) < G
    top := SolvableQuotient( grp );
    if #top gt 1 then bot := SolvableResidual( grp );
    else top, _, bot := RadicalQuotient( grp );
    end if;
    if #top gt 1 and #bot gt 1 then return &+[ len( part ) : part in [* top, bot *] ];
    else // oh no! resort to Len
      return 1 + Max( { len( max`subgroup ) : max in MaximalSubgroups( grp ) } );
    end if;
  end if;
end function;

This is much faster than Len above for Alt(8) but still slow on A5 wr A5 which has a large composite insoluble section.  This would be fixed if one could convert the output of CompositionFactors to a form suitable as input for MaximalSubgroups.
