We should all remember that this is a forum for snarky comments about Spyder. If you don't have any trivial complaints, ridiculous feature requests, or other nonsensical comments about Spyder, then this is not the place. If you need help with your Finite Math homework, please post to the PyDev forum instead.

On 4/10/2011 11:36 AM, Alexandra Sekalska wrote:
Thank you for the helpful and rapid answer.I扉e already solved the problems because of your explanations.Thanks again!

On Sun, Apr 10, 2011 at 7:06 PM, stefan <[email protected] <mailto:[email protected]>> wrote:

    This is not strictly a spyder question but rather general python but
    here goes:

    the gcd can be imported from module fractions
    >>> import fractions
    >>> fractions.gcd(120,70)
    10

    factorial is provided by the math module
    >>> import math
    >>> math.factorial(10)
    3628800

    Finding all divisors is a bit more involved (NP-hard problem) and
    there appears to be no readily provided function in a standard
    module
    (I might be wrong). Consider the highest-ranked answer in
    
http://stackoverflow.com/questions/171765/what-is-the-best-way-to-get-all-the-divisors-of-a-number
     and and the ensuing discussion. It should be straighforward to take
    what has been posted and use their function as is.

    Hope this helps, Stefan
    You are getting the ImportError because module math does not provide
    divisors:

    >>> import math
    >>> dir(math)
    ['__doc__', '__file__', '__name__', '__package__', 'acos', 'acosh',
    'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos',
    'cosh', 'degrees', 'e', 'exp', 'fabs', 'factorial', 'floor', 'fmod',
    'frexp', 'fsum', 'hypot', 'isinf', 'isnan', 'ldexp', 'log', 'log10',
    'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan',
    'tanh', 'trunc']



    On Apr 10, 7:09 am, Addicted <[email protected]
    <mailto:[email protected]>> wrote:
    > Hi there! I惴 new using Spyder and I惴 trying to calculate the
    > greatest common divisor (gcd), the factorial and the divisor of
    > numbers..I扉e tried on this way :
    >
    > from math import divisors
    > n=(divisors(712504))
    > print n
    >
    > but then ImportError: cannot import name divisors  appears
    > I searched on Internet but without a result.I need a help!

    --
    You received this message because you are subscribed to the Google
    Groups "spyder" group.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:spyderlib%[email protected]>.
    For more options, visit this group at
    http://groups.google.com/group/spyderlib?hl=en.


--
You received this message because you are subscribed to the Google Groups "spyder" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/spyderlib?hl=en.

--
Ariel Balter
arielbalter.com
509-713-0087

"Don't believe everything you think."

--
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/spyderlib?hl=en.

Reply via email to