Re: Fast way of checking for perfect squares?
- To: mathgroup at smc.vnet.net
- Subject: [mg83735] Re: Fast way of checking for perfect squares?
- From: giovanni resta <g.restaCUT at CUTiit.cnr.it>
- Date: Thu, 29 Nov 2007 06:28:58 -0500 (EST)
- References: <fhu6m6$6pd$1@smc.vnet.net>
michael.p.croucher at googlemail.com wrote:
> Hi
>
> Lets say I have a lot of large integers and I want to check to see
> which ones are perfect squares - eg
I've seen that Mathematica internally uses this function:
PerfectSquareQ[n_] :=
JacobiSymbol[n, 13] =!= -1 && JacobiSymbol[n, 19] =!= -1 &&
JacobiSymbol[n, 17] =!= -1 && JacobiSymbol[n, 23] =!= -1 &&
IntegerQ[Sqrt[n]];
g.