U
    Ç-e  ã                   @   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 ]H\‰}|D ]2\‰ }t‡ ‡fdd„td|d ƒD ƒƒrLd} q€qL|s@ qŠ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_iZp_j© úb/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/sympy/combinatorics/group_numbers.pyÚ
<listcomp>%   s     z'is_nilpotent_number.<locals>.<listcomp>r   F)ÚintÚ
ValueErrorr   Úlistr   ÚitemsÚanyÚrange)ÚnÚprime_factorsZis_nilpotentZa_jÚa_ir   r
   r   Úis_nilpotent_number   s    "r   c                 C   sZ   | dkst | ƒ| kr td|  ƒ‚t| ƒ} t| ƒs4d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   s   | ]\}}|d k V  qdS )é   Nr   ©r   r   r   r   r   r   Ú	<genexpr>P   s     z$is_abelian_number.<locals>.<genexpr>©r   r   r   r   r   r   r   Úall)r   r   Z
is_abelianr   r   r   Úis_abelian_number.   s    r   c                 C   sZ   | dkst | ƒ| kr td|  ƒ‚t| ƒ} t| ƒs4dS tt| ƒ ¡ ƒ}tdd„ |D ƒƒ}|S )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   s   | ]\}}|d k V  qdS )é   Nr   r   r   r   r   r   u   s     z#is_cyclic_number.<locals>.<genexpr>r   )r   r   Z	is_cyclicr   r   r   Úis_cyclic_numberT   s    r    N)	Z
sympy.corer   r   r   Zsympyr   r   r   r    r   r   r   r   Ú<module>   s   )&