nth root

Mark Dickinson dickinsm at gmail.com
Sat Jan 31 18:25:34 CET 2009


On Jan 31, 4:48 pm, Dan Goodman <dg.gm... at thesamovar.net> wrote:
> I don't think accuracy is too big a problem here actually (at least for
> 13th roots). I just tested it with several hundred thousand random 100
> digit numbers and it never made a mistake.

Well, random numbers is one thing.  But how about the following:

>>> n = 12345**13
>>> n
154662214940914131102165197707101295849230845947265625L
>>> int(n ** (1./13))  # should be 12345; okay
12345
>>> int((n-1) ** (1./13))  # should be 12344; oops!
12345

Mark




More information about the Python-list mailing list