On Sat, Aug 29, 2009 at 8:16 AM, Rolandb <rola...@planet.nl> wrote: > > Hi, > > I came across an amazing difference in execution time. Consider: > > sage: def heelsnel(reeks,maxum): > ... > ... def expon(mx,g): return floor(log(mx)/log(g))+1 > ... > ... if len(reeks)==1: return expon(maxum,reeks[0]) > ... tel=0 > ... for k in range(1,expon(maxum,reeks[-1])): > ... tel+=heelsnel(reeks[:-1],int(maxum/reeks[-1]^k)) > ... return tel >
Can you post a version where I can actually paste in the code? You probably have this in a file somewhere without the sage: and ... prompts. -- William > > For example if reeks=[2,3] the execution is fast. Thus: > sage: heelsnel([2,3],10^8+1) > > Also for all other combinations of p,q, thus reeks=[p,q]. There is one > weird execption: reeks=[2,5], e.g. > sage: heelsnel([2,5],10^8+1). > > Profile.run shows that suddenly many functions are called which seems > odd for such a simple recursive function. Why? > > Thanks in advance! > > Rolandb > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---