dickinsm at gmail.com
Sat Jan 31 13:24:56 CET 2009
On Jan 31, 5:43 am, "Tim Roberts" <t.robe... at cqu.edu.au> wrote:
> Thanks - you're probably right - just my intuition said to me that rather than calculating that the 13th root of 4021503534212915433093809093996098953996019232
> is 3221.2904208350265....
> there must be a quicker way of finding out its between 3221 and 3222....
> ....but perhaps not.
I don't think you'll find anything much quicker than n**(1./13)
(though I hope
that if you're doing this millions of time then you're precomputing
rather than redoing the division every single time.
What happens behind the scenes here is that your integer is
converted to a float, then the system math library is used for the
power operation. The integer -> float conversion is probably quite
I'd also be a bit worried about accuracy. Is it important to you
integer part of the result is *exactly* right, or is it okay if
(n**13)**(1./13) sometimes comes out as slightly less than n, or if
(n**13-1)**(1./13) sometimes comes out as n?
More information about the Python-list