Thank you for the helpful and rapid answer.I´ve already solved the problems because of your explanations.Thanks again!
On Sun, Apr 10, 2011 at 7:06 PM, stefan <[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]> wrote: > > Hi there! I´m new using Spyder and I´m trying to calculate the > > greatest common divisor (gcd), the factorial and the divisor of > > numbers..I´ve 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]. > 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. > > -- 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.
