(n)
return G
Generates the alternating group on ``n`` elements as a permutation group.

    For ``n > 2``, the generators taken are ``(0 1 2), (0 1 2 ... n-1)`` for
    ``n`` odd
    and ``(0 1 2), (1 2 ... n-1)`` for ``n`` even (See [1], p.31, ex.6.9.).
    After the group is generated, some of its basic properties are set.
    The cases ``n = 1, 2`` are handled separately.

    Examples
    ========

    >>> from sympy.combinatorics.named_groups import AlternatingGroup
    >>> G = AlternatingGroup(4)
    >>> G.is_group()
    False
    >>> a = list(G.generate_dimino())
    >>> len(a)
    12
    >>> all(perm.is_even for perm in a)
    True

    See Also
    ========

    SymmetricGroup, CyclicGroup, DihedralGroup

    References
    ==========

    [1] Armstrong, M. "Groups and Symmetry"
Generates the alternating group on ``n`` elements as a permutation group.
Generates the alternating group on n elements as a permutation group .
def AlternatingGroup(n):
    """
    Generates the alternating group on ``n`` elements as a permutation group.

    For ``n > 2``, the generators taken are ``(0 1 2), (0 1 2 ... n-1)`` for
    ``n`` odd
    and ``(0 1 2), (1 2 ... n-1)`` for ``n`` even (See [1], p.31, ex.6.9.).
    After the group is generated, some of its basic properties are set.
    The cases ``n = 1, 2`` are handled separately.

    Examples
    ========

    >>> from sympy.combinatorics.named_groups import AlternatingGroup
    >>> G = AlternatingGroup(4)
    >>> G.is_group()
    False
    >>> a = list(G.generate_dimino())
    >>> len(a)
    12
    >>> all(perm.is_even for perm in a)
    True

    See Also
    ========

    SymmetricGroup, CyclicGroup, DihedralGroup

    References
    ==========

    [1] Armstrong, M. "Groups and Symmetry"

    """
    # small cases are special
    if n in (1, 2):
        return PermutationGroup([Permutation([0])])

    a = list(range(n))
    a[0], a[1], a[2] = a[1], a[2], a[0]
    gen1 = a
    if n % 2:
        a = list(range(1, n))
        a.append(0)
        gen2 = a
    else:
        a = list(range(2, n))
        a.append(1)
        a.insert(0, 0)
        gen2 = a
    gens = [gen1, gen2]
    if gen1 == gen2:
        gens = gens[:1]
    G = PermutationGroup([_af_new(a) for a in gens], dups=False)

    if n < 4:
        G._is_abelian = True
        G._is_nilpotent = True
    else:
        G._is_abelian = False
        G._is_nilpotent = False
    if n < 5:
        G._is_solvable = True
    else:
        G._is_solvable = False
    G._degree = n
    G._is_transitive = True
    G._is_alt = True
    return G
def AlternatingGroup ( n ) : # small cases are special if n in ( 1 , 2 ) : return PermutationGroup ( [ Permutation ( [ 0 ] ) ] ) a = list ( range ( n ) ) a [ 0 ] , a [ 1 ] , a [ 2 ] = a [ 1 ] , a [ 2 ] , a [ 0 ] gen1 = a if n % 2 : a = list ( range ( 1 , n ) ) a . append ( 0 ) gen2 = a else : a = list ( range ( 2 , n ) ) a . append ( 1 ) a . insert ( 0 , 0 ) gen2 = a gens = [ gen1 , gen2 ] if gen1 == gen2 : gens = gens [ : 1 ] G = PermutationGroup ( [ _af_new ( a ) for a in gens ] , dups = False ) if n < 4 : G . _is_abelian = True G . _is_nilpotent = True else : G . _is_abelian = False G . _is_nilpotent = False if n < 5 : G . _is_solvable = True else : G . _is_solvable = False G . _degree = n G . _is_transitive = True G . _is_alt = True return G