Updates:
        Status: WontFix

Comment #4 on issue 4019 by [email protected]: divisors could use a 'pairs' flag
http://code.google.com/p/sympy/issues/detail?id=4019

def divisor_pairs(n):
    """Return pairs of divisors of n, (a, b), such that a <= b. A
    generator of pairs (not necessarily in order) is returned.

    Examples
    ========

    >>> from sympy import divisor_pairs
    >>> list(divisor_pairs(24))
    [(1, 24), (2, 12), (4, 6), (3, 8)]
    """
    for d in divisors(n, generator=True):
        if d <= n//d:
            yield (d, n // d)

But perhaps this is just something that should go in one's personal library. A one-liner in spirit of yours is

n=120
[(d, n//d) for d in divisors(n, True) if d <= n//d]
[(1, 120), (2, 60), (4, 30), (8, 15), (3, 40), (6, 20), (5, 24), (10, 12)]

I'll close this unless there is a second to add such a function. As a point of reference, Wolfram has lots of utility functions related to divisors, like "common divisors of A and B" and "common multiples of A and B".

Perhaps this gets down to questions about what qualifies as being a useful tool in the CAS environment. Just being able to get the divisors (or lcm or gcd) is enough to do more complex tasks. But whether the codebase should have those added or not is the question.

In teaching algebra, it makes sense to look at divisor pairs rather than just the divisors.

So...if anyone else thinks this should be in SymPy I will submit a patch, otherwise this is closed.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to