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

# sympy.ntheory.factor_.divisors

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
```Return all divisors of n sorted from 1..n by default.
If generator is True an unordered generator is returned.

The number of divisors of n can be quite large if there are many
prime factors (counting repeated factors). If only the number of
factors is desired use divisor_count(n).

Examples
========
(more...)
```

```        def divisors(n, generator=False):
r"""
Return all divisors of n sorted from 1..n by default.
If generator is True an unordered generator is returned.

The number of divisors of n can be quite large if there are many
prime factors (counting repeated factors). If only the number of
factors is desired use divisor_count(n).

Examples
========

>>> from sympy import divisors, divisor_count
>>> divisors(24)
[1, 2, 3, 4, 6, 8, 12, 24]
>>> divisor_count(24)
8

>>> list(divisors(120, generator=True))
[1, 2, 4, 8, 3, 6, 12, 24, 5, 10, 20, 40, 15, 30, 60, 120]

This is a slightly modified version of Tim Peters referenced at:
http://stackoverflow.com/questions/1010381/python-factorization

========

primefactors, factorint, divisor_count
"""

n = int(abs(n))
if isprime(n):
return [1, n]
if n == 1:
return 
if n == 0:
return []
rv = _divisors(n)
if not generator:
return sorted(rv)
return rv
```

```from sympy.simplify.simplify import _mexpand, _is_sum_surds
from sympy.ntheory import sieve
from sympy.ntheory.factor_ import divisors
from sympy.mpmath import pslq, mp

```
```
# x**(2*q) = product(factors)
factors = [cyclotomic_poly(i, x) for i in divisors(2*q)]
mp = _choose_factor(factors, x, ex)
return mp
```