MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Fast way of checking for perfect squares?


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.


  • Prev by Date: Re: Convert nxn matrix to a column vector with (n^2) elements
  • Next by Date: Re: Convert nxn matrix to a column vector with (n^2)
  • Previous by thread: Re: Fast way of checking for perfect squares?
  • Next by thread: Matching string in Mathematica