+
    ‹°³jË#  ã                   ó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   "Úb/home/luca/screen-checking/.venv/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# )z«Check 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   € ð �\‰\Ž^ˆØ—M‘M–O‰DˆAð ˆAÜ˜1–X�Ø•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ØˆA„vÜÐ?À!Õ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   é € Ð/Ñ.˜�1ŽuÓ.ùó   ‚FT©r   r!   r   ÚallÚvaluesr   ©r"   r
   s   & r   Úis_abelian_numberr2   8   sk   € ô4 	ˆq‹	€AØˆA„vÜÐ?À!ÕCÓDÐDÜ˜‹l€Gß‹3Ñ/˜gŸn™nÔ.Ó/�3�3Š3Ñ/˜gŸn™nÔ.Ó/Ó/×QÐQÔ4HÈÓ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Ñ/˜!�AŽvÓ/ùr-   FTr.   r1   s   & r   Úis_cyclic_numberr9   Y   sk   € ô4 	ˆq‹	€AØˆA„vÜÐ?À!ÕCÓDÐDÜ˜‹l€Gß‹3Ñ0˜wŸ~™~Ô/Ó0�3�3Š3Ñ0˜wŸ~™~Ô/Ó0Ó0×RÐRÔ5IÈ'Ó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ó   ù€ ñ~ "ÔL‘Mˆq§S£SÔ(K¹]Ó(K§S§S¢SÔ(K¹]Ó(K×%K�ˆ‘M€AÐLØÕ€Aà	€AÜ×"Ò"Ô"O¼uÄSÈÃVÈAÅX¼Ó"OÓO€HÛˆÜ�‹WˆØˆØ�R—�ˆAÜ ¦Ó5¡˜1¨a­%°1©*—Q�Q¡Ñ5Ó6ˆAØ�Q˜•T˜A•X 1 q¥5Õ)Õ)ˆ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   é € Ð
+Ñ*�QˆqŽ5Ó*ù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   ¥NÙC )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ØˆA„vÜÐ?À!ÕCÓDÐDÜ˜‹l€GÜ
ˆ7ƒ|�qÕÜ�g—m‘m“oÓ& qÕ)‰ˆØ�Œ6ÚSˆGØ”3�w“<ÔØ•zÐ!Ø�Œ6ÚJˆGØ”3�w“<ÔØ•zÐ!Ø�Œ6ØˆHØ�Œ6ÙØ�Œ6ÙØ�Œ6Ø˜˜!�•8˜a¤ A a¥C¨£�mÕ+¬c°!°Aµ#°q«kÕ9Ð9Ø�Œ6Ø�Q˜•T•6˜B˜q�D•= 3Õ&Ø”S˜˜1�˜a“[•.õ!Ø#%¤c¨!¨A­#¨q£k¥>õ2Ø45´c¸!¸A½#¸q³kµMõBð Bà��6Ø�AŒvÙØ�Q˜•T•6˜B˜q !�t�GÕ# b¨¨A­¥gÕ-°°A°qµDµÕ8¸3¸q½5Õ@À4ÕGØ�Q˜•T•6˜B˜q�D•= 3Õ&¬¨A¨a­C°«Õ3õ4Ø78¸!µt¸bÀ½dµ{ÀSÕ7HÌ#ÈaÐPQÍcÐSTË+Õ6UõVà�Q•3˜•8œS  1¥ a›[Õ(õ)à+,¬S°°1µ°a«[­=õ9à;<¼SÀÀ1ÅÀa»[½=õIäKNÈqÐQRÍsÐTUË;õWð W÷ ƒsÑ
+˜'Ÿ.™.Ô*Ó
+‡s‡s‚sÑ
+˜'Ÿ.™.Ô*Ó
+×+Ò+ð7��Qð 7˜˜Að 7˜r 1ð 7 b¨"ð 7¨b°!ð 7°R¸ð 7¸RÀð 7ÀRÈð 7ÈBÐPQð 7ÐSUÐWYð 7Ø�Að7Ø˜1ð7Ø  "ð7Ø&(¨"ð7Ø.0°"ð7Ø68¸!ð7Ø=?Àð7ØDFÈÈBÐPQÐSUÐWXØ�B˜˜B  B¨¨B°°Añ7ˆð Œ:Ø•8ˆOÜÐTÓUÐUÜ
ˆ7ƒ|�qÔÜ�g—l‘l“nÓ%‰ˆØ•E˜Q”JˆqÐ% AÐ%Üœ3˜wŸ|™|›~Ó.Ó/Ð/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   