+
    i                     0    ^ RI Ht R tR tR t]3R ltR# )    )as_intc                    \        V 4      p ^ V 3^V ^ 3^/p^p\        ^V ^,          ^,           4       F9  pW V,
          ^,           ,          V,          pV;WW,
          3&   WV,
          V3&   K;  	  V# )a  Return a dictionary containing pairs :math:`{(k1,k2) : C_kn}` where
:math:`C_kn` are binomial coefficients and :math:`n=k1+k2`.

Examples
========

>>> from sympy.ntheory import binomial_coefficients
>>> binomial_coefficients(9)
{(0, 9): 1, (1, 8): 9, (2, 7): 36, (3, 6): 84,
 (4, 5): 126, (5, 4): 126, (6, 3): 84, (7, 2): 36, (8, 1): 9, (9, 0): 1}

See Also
========

binomial_coefficients_list, multinomial_coefficients
r   rangendaks   &   y/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/ntheory/multinomial.pybinomial_coefficientsr      sx    " 	q	A
QQFAA	A1adQha%!)_q $%%QU(aAqk   H    c                    \        V 4      p ^.V ^,           ,          p^p\        ^V ^,          ^,           4       F/  pW V,
          ^,           ,          V,          pV;W&   WV,
          &   K1  	  V# )a#  Return a list of binomial coefficients as rows of the Pascal's
triangle.

Examples
========

>>> from sympy.ntheory import binomial_coefficients_list
>>> binomial_coefficients_list(9)
[1, 9, 36, 84, 126, 126, 84, 36, 9, 1]

See Also
========

binomial_coefficients, multinomial_coefficients
r   r   s   &   r   binomial_coefficients_listr      sg      	q	A	
q1uA	A1adQha%!)_q qQx   Hr   c                   \        V 4      p \        V4      pV '       g   V'       d   / # R^/# V ^8X  d   \        V4      # V ^V,          8  d   V^8  d   \        \        W4      4      # V.^ .V ^,
          ,          ,           p\	        V4      ^/pV'       d   ^ pMT pW@^,
          8  Ed   W$,          pV'       d	   ^ W$&   WR^ &   V^8  d#   W$^,           ;;,          ^,          uu&   ^ p^p^ pM8V^,          pV^,           pV\	        V4      ,          pW$;;,          ^,          uu&   \        W`4       FS  pW(,          '       g   K  W(;;,          ^,          uu&   Ws\	        V4      ,          ,          pW(;;,          ^,          uu&   KU  	  V^ ;;,          ^,          uu&   Wu,          W^ ,          ,
          ,          V\	        V4      &   EK)  V# )a  Return a dictionary containing pairs ``{(k1,k2,..,km) : C_kn}``
where ``C_kn`` are multinomial coefficients such that
``n=k1+k2+..+km``.

Examples
========

>>> from sympy.ntheory import multinomial_coefficients
>>> multinomial_coefficients(2, 5) # indirect doctest
{(0, 5): 1, (1, 4): 5, (2, 3): 10, (3, 2): 10, (4, 1): 5, (5, 0): 1}

Notes
=====

The algorithm is based on the following result:

.. math::
    \binom{n}{k_1, \ldots, k_m} =
    \frac{k_1 + 1}{n - k_1} \sum_{i=2}^m \binom{n}{k_1 + 1, \ldots, k_i - 1, \ldots}

Code contributed to Sage by Yann Laigle-Chapuy, copied with permission
of the author.

See Also
========

binomial_coefficients_list, binomial_coefficients
 )r   r   dict!multinomial_coefficients_iteratortupler   )	mr   trjtjstartvr   s	   &&       r   multinomial_coefficientsr   7   si   : 	q	Aq	AIAwAv$Q''AaCxAE5a;<<	
qcQUmA	q1A
!e)TADaD6!eHMHAEAFAEE%(ADAID uAtt	uQx[ 		 !
 	
!	v1t8,%(Hr   c           	   #    "   \        V 4      p \        V4      pV ^V,          8  g   V^8X  d&   \        W4      pVP                  4        Rj  xL
  R# \        W4      p/ pVP                  4        F  w  rVWdV! \        RV4      4      &   K  	  TpV.^ .V ^,
          ,          ,           pV! V4      pV! \        RV4      4      p	WV	,          3x  V'       d   ^ p
MT p
W^,
          8  d   Wz,          pV
'       d	   ^ Wz&   W^ &   V^8  d   Wz^,           ;;,          ^,          uu&   ^ p
MV
^,          p
Wz;;,          ^,          uu&   V^ ;;,          ^,          uu&   V! V4      pV! \        RV4      4      p	WV	,          3x  K  R#  EL55i)a1  multinomial coefficient iterator

This routine has been optimized for `m` large with respect to `n` by taking
advantage of the fact that when the monomial tuples `t` are stripped of
zeros, their coefficient is the same as that of the monomial tuples from
``multinomial_coefficients(n, n)``. Therefore, the latter coefficients are
precomputed to save memory and time.

>>> from sympy.ntheory.multinomial import multinomial_coefficients
>>> m53, m33 = multinomial_coefficients(5,3), multinomial_coefficients(3,3)
>>> m53[(0,0,0,1,2)] == m53[(0,0,1,0,2)] == m53[(1,0,2,0,0)] == m33[(0,1,2)]
True

Examples
========

>>> from sympy.ntheory.multinomial import multinomial_coefficients_iterator
>>> it = multinomial_coefficients_iterator(20,3)
>>> next(it)
((3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 1)
N)r   r   itemsfilter)r   r   _tuplemcmc1r   r   r   t1br   r   s   &&&         r   r   r      sR    , 	q	Aq	A1Q3w!q&%a+88:%a+HHJDA+,vdA'( C1#Q-AY6$#$a5kAAa%iB!Ava%AQ	aDAIDBvdB'(A!u+! # 	s   A
FFD5FN)sympy.utilities.miscr   r   r   r   r   r   r   r   r   <module>r'      s#    '42GT 49 ;r   