+
    i#                     v    ^ RI HtHt ^ RIHt ^ RIHt ^ RIHt R R lt	R R lt
R	 R
 ltR R ltR tR tR# )    )chaincombinations)gcd)	factorint)as_intc                0    V ^8  d   QhR\         R\        /# )   factorsreturn)dictbool)formats   "_/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/combinatorics/group_numbers.py__annotate__r      s      $ 4     c                    V P                  4        FK  pV P                  4        F4  w  r#^p\        V4       F  pWB,          V,          pV^8X  g   K     R# 	  K6  	  KM  	  R# )zCheck whether `n` is a nilpotent number.
Note that ``factors`` is a prime factorization of `n`.

This is a low-level helper for ``is_nilpotent_number``, for internal use.
FT)keysitemsrange)r
   pqem_s   &     r   _is_nilpotent_numberr      sU     \\^MMODA A1XC!G6  	 $  r   c                $    V ^8  d   QhR\         /# r	   r   r   )r   s   "r   r   r      s     . .d .r   c                r    \        V 4      p V ^ 8:  d   \        RV ,          4      h\        \        V 4      4      # )a&  
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.
.. [2] https://oeis.org/A056867

$n must be a positive integer, not %i)r   
ValueErrorr   r   )ns   &r   is_nilpotent_numberr#      s4    0 	q	AAv?!CDD	!--r   c                $    V ^8  d   QhR\         /# r   r   )r   s   "r   r   r   8   s     R RD Rr   c                &   \        V 4      p V ^ 8:  d   \        RV ,          4      h\        V 4      p\        ;QJ d*    R VP	                  4        4       F  '       d   K   RM	  RM! R VP	                  4        4       4      ;'       d    \        V4      # )a:  
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.
.. [2] https://oeis.org/A051532

r    c              3   *   "   T F	  q^8  x  K  	  R# 5i)   N .0r   s   & r   	<genexpr>$is_abelian_number.<locals>.<genexpr>V   s     /.1u.   FTr   r!   r   allvaluesr   r"   r
   s   & r   is_abelian_numberr2   8   sk    4 	q	AAv?!CDDlG3/gnn./333/gnn.//QQ4H4QQr   c                $    V ^8  d   QhR\         /# r   r   )r   s   "r   r   r   Y   s     S S4 Sr   c                &   \        V 4      p V ^ 8:  d   \        RV ,          4      h\        V 4      p\        ;QJ d*    R VP	                  4        4       F  '       d   K   RM	  RM! R VP	                  4        4       4      ;'       d    \        V4      # )a3  
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.
.. [2] https://oeis.org/A003277

r    c              3   *   "   T F	  q^8H  x  K  	  R# 5i   Nr(   r)   s   & r   r+   #is_cyclic_number.<locals>.<genexpr>w   s     0/!Av/r-   FTr.   r1   s   & r   is_cyclic_numberr9   Y   sk    4 	q	AAv?!CDDlG30w~~/03330w~~/00RR5I'5RRr   c           	     f  aa	 V  Uau0 uFG  o\         ;QJ d    V3R lV  4       F  '       d   K   RM	  RM! V3R lV  4       4      '       g   KE  SkKI  	  ppW,
          o	^ p\        P                  ! V	3R l\        \	        S	4      ^,           4       4       4      pV F  p\        V4      p^pS	V,
           Fb  o\	        W%,           Uu. uF  qwS,          ^8X  g   K  VNK  	  up4      pVSV,          ^,
          S^,
          ,          ,          pV'       d   Kb   M	  W6,          pK  	  V# u upi u upi )a  Number of groups of order `n`.
where `n` is squarefree and its prime factors are ``prime_factors``.
i.e., ``n == math.prod(prime_factors)``

Explanation
===========

When `n` is squarefree, the number of groups of order `n` is expressed by

.. math ::
    \sum_{d \mid n} \prod_p \frac{p^{c(p, d)} - 1}{p - 1}

where `n=de`, `p` is the prime factor of `e`,
and `c(p, d)` is the number of prime factors `q` of `d` such that `q \equiv 1 \pmod{p}` [2]_.

The formula is elegant, but can be improved when implemented as an algorithm.
Since `n` is assumed to be squarefree, the divisor `d` of `n` can be identified with the power set of prime factors.
We let `N` be the set of prime factors of `n`.
`F = \{p \in N : \forall q \in N, q \not\equiv 1 \pmod{p} \}, M = N \setminus F`, we have the following.

.. math ::
    \sum_{d \in 2^{M}} \prod_{p \in M \setminus d} \frac{p^{c(p, F \cup d)} - 1}{p - 1}

Practically, many prime factors are expected to be members of `F`, thus reducing computation time.

Parameters
==========

prime_factors : set
    The set of prime factors of ``n``. where `n` is squarefree.

Returns
=======

int : Number of groups of order ``n``

Examples
========

>>> from sympy.combinatorics.group_numbers import _holder_formula
>>> _holder_formula({2}) # n = 2
1
>>> _holder_formula({2, 3}) # n = 2*3 = 6
2

See Also
========

groups_count

References
==========

.. [1] Otto Holder, Die Gruppen der Ordnungen p^3, pq^2, pqr, p^4,
       Math. Ann. 43 pp. 301-412 (1893).
       http://dx.doi.org/10.1007/BF01443651
.. [2] John H. Conway, Heiko Dietrich and E.A. O'Brien,
       Counting groups: gnus, moas and other exotica
       The Mathematical Intelligencer 30, 6-15 (2008)
       https://doi.org/10.1007/BF02985731

c              3   :   <"   T F  qS,          ^8g  x  K  	  R# 5ir6   r(   )r*   r   r   s   & r   r+   "_holder_formula.<locals>.<genexpr>   s     (K]Q!]s   FTc              3   <   <"   T F  p\        SV4      x  K  	  R # 5i)N)r   )r*   rMs   & r   r+   r<      s     "O!<1#5#5s   )r/   r   from_iterabler   lenset)
prime_factorsr   Fspowersetpsprodr   cr?   s
   &`       @r   _holder_formularJ   z   s    ~ "LMqSS(K](KSSS(K](K%KMALA	A"""OuSVAX"OOHWRA51a%1*QQ56AQTAX1q5))D4	 
 	
	  H 	M 6s!   D)D)D)D)D.D.c                H   \        V 4      p V ^ 8:  d   \        RV ,          4      h\        V 4      p\        V4      ^8X  Ed   \	        VP                  4       4      ^ ,          w  r#V^8X  d   . ROpV\        V4      8  d	   WC,          # V^8X  d   . ROpV\        V4      8  d	   WS,          # V^8:  d   V# V^8X  d   ^# V^8X  d   ^# V^8X  dH   ^=^V,          ,           ^\        V^,
          ^4      ,          ,           \        V^,
          ^4      ,           # V^8X  d   ^V^,          ,          ^'V,          ,           R,           ^\        V^,
          ^4      ,          ,           ^\        V^,
          ^4      ,          ,           ^\        V^,
          ^4      ,          ,           # V^8X  Edn   V^8X  d   R# ^V^,          ,          ^V^,          ,          ,           ^,V^,          ,          ,           ^V^,          ,          ,           RV,          ,           R,           ^V^,          ,          ^,V,          ,           R,           \        V^,
          ^4      ,          ,           V^,          ^V,          ,           ^,           \        V^,
          ^4      ,          ,           ^V,          ^,           \        V^,
          ^4      ,          ,           ^\        V^,
          ^4      ,          ,           ^\        V^,
          ^4      ,          ,           \        V^,
          ^	4      ,           # \        ;QJ d*    R VP                  4        4       F  '       g   K   RM	  R	M! R VP                  4        4       4      '       da   / ^^b^^b^^b^^b^^b^$^b^(^b^,^b^-^b^0^4b^2^b^4^b^6^b^8^b^<^b^?^b^D^b^H^2^K^^L^^P^4^T^^X^^Z^
^\^/CpW9   d	   W`,          # \        R
4      h\        V4      ^8X  d-   \        VP                  4       4      w  r'Wr,          ^8X  d   ^# ^# \        \        VP                  4       4      4      # )a  Number of groups of order `n`.
In [1]_, ``gnu(n)`` is given, so we follow this notation here as well.

Parameters
==========

n : Integer
    ``n`` is a positive integer

Returns
=======

int : ``gnu(n)``

Raises
======

ValueError
    Number of groups of order ``n`` is unknown or not implemented.
    For example, gnu(`2^{11}`) is not yet known.
    On the other hand, gnu(99) is known to be 2,
    but this has not yet been implemented in this function.

Examples
========

>>> from sympy.combinatorics.group_numbers import groups_count
>>> groups_count(3) # There is only one cyclic group of order 3
1
>>> # There are two groups of order 10: the cyclic group and the dihedral group
>>> groups_count(10)
2

See Also
========

is_cyclic_number
    `n` is cyclic iff gnu(n) = 1

References
==========

.. [1] John H. Conway, Heiko Dietrich and E.A. O'Brien,
       Counting groups: gnus, moas and other exotica
       The Mathematical Intelligencer 30, 6-15 (2008)
       https://doi.org/10.1007/BF02985731
.. [2] https://oeis.org/A000001

r    iX  i  i  i	  i#  c              3   *   "   T F	  q^8  x  K  	  R# 5ir6   r(   r)   s   & r   r+   groups_count.<locals>.<genexpr>  s     
+*Qq5*r-   TFz9Number of groups of order n is unknown or not implemented)r7   r7   r	         3   i  i	  i  i! l   yLZ. )
r7   r7   r	   rN      C   i  i^$  imM l   NC )r   r!   r   rA   listr   r   anyr0   sortedr   rJ   rB   )r"   r
   r   r   A000679A090091smallr   s   &       r   groups_countrY      s   d 	q	AAv?!CDDlG
7|qgmmo&q)6SG3w<z!6JG3w<z!6H666!8aAaCm+c!A#qk996QT6BqD=3&S1a[.!#%c!A#qk>245c!A#qkMB B6AvQT6Bq!tG#bAg-AqD83q5@4GQT6BqD=3&AaC3478!tbd{S7H#aPQcST+6UVQ38S1a[()+,S1a[=9;<S1a[=IKNqQRsTU;W W s
+'..*
+sss
+'..*
+++7Q 7A 7r1 7b" 7b! 7R 7R 7R 7BPQ 7SUWY 7A717 "7&("7.0"768!7=?7DFBPQSUWXBBBBA7 :8OTUU
7|qglln%EQJq%A%3w||~.//r   N)	itertoolsr   r   sympy.external.gmpyr   sympy.ntheory.factor_r   sympy.utilities.miscr   r   r#   r2   r9   rJ   rY   r(   r   r   <module>r^      s6    ) # + '$.<RBSBM`\0r   