On Feb 1, 2:27 am, casevh <cas...@gmail.com> wrote:
> On Jan 31, 9:36 pm, "Tim Roberts" <t.robe...@cqu.edu.au> wrote:
>
> > Actually, all I'm interested in is whether the 100 digit numbers have an 
> > exact integral root, or not.  At the moment, because of accuracy concerns, 
> > I'm doing something like
>
> >                     for root in powersp:
> >                             nroot = round(bignum**(1.0/root))
> >                             if bignum==long(nroot)**root:
> >                                                              .........
> > which is probably very inefficient, but I can't see anything better.....
>
> > Tim
>
> Take a look at gmpy and the is_power function. I think it will do
> exactly what you want.

And the root function will give you the root AND tell you whether
it was an integral root:

>>> gmpy.root(a,13)
(mpz(3221), 0)

In this case, it wasn't.

>
> http://code.google.com/p/gmpy/
>
> casevh

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to