Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(33)  |  Call(30)  |  Derive(0)  |  Import(3)
Count the number of trailing zero digits in the binary
representation of n, i.e. determine the largest power of 2
that divides n.

Examples
========

>>> from sympy import trailing
>>> trailing(128)
7(more...)

        def trailing(n):
    """Count the number of trailing zero digits in the binary
    representation of n, i.e. determine the largest power of 2
    that divides n.

    Examples
    ========

    >>> from sympy import trailing
    >>> trailing(128)
    7
    >>> trailing(63)
    0
    """
    n = int(n)
    if not n:
        return 0
    low_byte = n & 0xff
    if low_byte:
        return small_trailing[low_byte]

    # 2**m is quick for z up through 2**30
    z = bitcount(n) - 1
    if isinstance(z, SYMPY_INTS):
        if n == 1 << z:
            return z

    t = 0
    p = 8
    while not n & 1:
        while not n & ((1 << p) - 1):
            n >>= p
            t += p
            p *= 2
        p //= 2
    return t
        


src/s/y/sympy-HEAD/sympy/ntheory/tests/test_ntheory.py   sympy(Download)
from sympy.core.compatibility import long
 
from sympy.ntheory import isprime, n_order, is_primitive_root, \
    is_quad_residue, legendre_symbol, jacobi_symbol, npartitions, totient, \
    factorint, primefactors, divisors, randprime, nextprime, prevprime, \
def test_trailing():
    assert trailing(0) == 0
    assert trailing(1) == 0
    assert trailing(-1) == 0
    assert trailing(2) == 1

src/s/y/sympy-polys-HEAD/sympy/ntheory/tests/test_ntheory.py   sympy-polys(Download)
from sympy import Sieve, binomial_coefficients, binomial_coefficients_list, \
        multinomial_coefficients, raises, Mul, S, Pow
from sympy.ntheory import isprime, n_order, is_primitive_root, \
    is_quad_residue, legendre_symbol, npartitions, totient, \
    factorint, primefactors, divisors, randprime, nextprime, prevprime, \
def test_trailing():
    assert trailing(0) == 0
    assert trailing(1) == 0
    assert trailing(-1) == 0
    assert trailing(2) == 1

src/s/y/sympy-0.7.5/sympy/ntheory/tests/test_ntheory.py   sympy(Download)
from sympy.core.compatibility import long
 
from sympy.ntheory import isprime, n_order, is_primitive_root, \
    is_quad_residue, legendre_symbol, jacobi_symbol, npartitions, totient, \
    factorint, primefactors, divisors, randprime, nextprime, prevprime, \
def test_trailing():
    assert trailing(0) == 0
    assert trailing(1) == 0
    assert trailing(-1) == 0
    assert trailing(2) == 1