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

# sympy.ntheory.trailing

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
```

```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
```

```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, \
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
```

```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
```