o
    *ήc                     @   s<   d dl mZmZmZ d dlmZ dd Zdd Zdd Zd	S )
    )IntegerPowMod)	factorintc                    s   | dks
t | | krtd|  t| } tt|  }d}|D ]%\}|D ]\ }t fddtd|d D r?d} nq&|sE |S q |S )aJ  
    Check whether `n` is a nilpotent number. A number `n` is said to be
    nilpotent if and only if every finite group of order `n` is nilpotent.
    For more information see [1]_.

    Examples
    ========

    >>> from sympy.combinatorics.group_numbers import is_nilpotent_number
    >>> from sympy import randprime
    >>> is_nilpotent_number(21)
    False
    >>> is_nilpotent_number(randprime(1, 30)**12)
    True

    References
    ==========

    .. [1] Pakianathan, J., Shankar, K., *Nilpotent Numbers*,
            The American Mathematical Monthly, 107(7), 631-634.


    r   $n must be a positive integer, not %iTc                    s    g | ]}t t |d kqS )   )r   r   ).0kp_ip_j H/tmp/pip-target-vg8gfxp4/lib/python/sympy/combinatorics/group_numbers.py
<listcomp>%   s     z'is_nilpotent_number.<locals>.<listcomp>r   F)int
ValueErrorr   listr   itemsanyrange)nprime_factorsis_nilpotenta_ja_ir   r
   r   is_nilpotent_number   s    "r   c                 C   Z   | dks
t | | krtd|  t| } t| sdS tt|  }tdd |D }|S )af  
    Check whether `n` is an abelian number. A number `n` is said to be abelian
    if and only if every finite group of order `n` is abelian. For more
    information see [1]_.

    Examples
    ========

    >>> from sympy.combinatorics.group_numbers import is_abelian_number
    >>> from sympy import randprime
    >>> is_abelian_number(4)
    True
    >>> is_abelian_number(randprime(1, 2000)**2)
    True
    >>> is_abelian_number(60)
    False

    References
    ==========

    .. [1] Pakianathan, J., Shankar, K., *Nilpotent Numbers*,
            The American Mathematical Monthly, 107(7), 631-634.


    r   r   Fc                 s       | ]	\}}|d k V  qdS )   Nr   r   r   r   r   r   r   	<genexpr>P       z$is_abelian_number.<locals>.<genexpr>r   r   r   r   r   r   r   all)r   r   
is_abelianr   r   r   is_abelian_number.   s   r%   c                 C   r   )a^  
    Check whether `n` is a cyclic number. A number `n` is said to be cyclic
    if and only if every finite group of order `n` is cyclic. For more
    information see [1]_.

    Examples
    ========

    >>> from sympy.combinatorics.group_numbers import is_cyclic_number
    >>> from sympy import randprime
    >>> is_cyclic_number(15)
    True
    >>> is_cyclic_number(randprime(1, 2000)**2)
    False
    >>> is_cyclic_number(4)
    False

    References
    ==========

    .. [1] Pakianathan, J., Shankar, K., *Nilpotent Numbers*,
            The American Mathematical Monthly, 107(7), 631-634.

    r   r   Fc                 s   r   )   Nr   r   r   r   r   r    u   r!   z#is_cyclic_number.<locals>.<genexpr>r"   )r   r   	is_cyclicr   r   r   is_cyclic_numberT   s   r(   N)	
sympy.corer   r   r   sympyr   r   r%   r(   r   r   r   r   <module>   s
    )&