I've been discussing a problem with someone on the tutor list. It has to do with computing the sum of the proper divisors of a number. I suggested that he check out the sympy ntheory module. He did and is getting dismal results that are very different from mine. Does anyone have an idea what the problem might be? It's really a garden variety problem. Should be too difficult. On my system the following tests are both almost instantaneous but for him, use of sympy took about 1 minute. Any ideas why that might be? He has downloaded the most recent sympy and python 2.6. Details about his system are referenced at the end of this post.
> Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit > (Intel)] > Type "help", "copyright", "credits" or "license" for more information. >>>> from sympy import divisors >>>> > def proper_divisors_sum1(n): > pd = set((1,)) > for x in xrange(2, int(n**.5)+1): > if n % x == 0: > pd.update((x, n//x)) > return sum(pd) >>>> n = 2**29 >>>> proper_divisors_sum1(n) > 536870911 >>>> > def proper_divisors_sum2(n): > return sum(list(divisors(n)))-n >>>> proper_divisors_sum2(n) > 536870911 >>>> > > with n = 2**29, > proper_divisors_sum1(n) was apparently instantantaneous > proper_divisors_sum2(n) took ~59 secs. > laptop information: http://tutoree7.pastebin.com/AXEigSLq -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sy...@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.