Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

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.


  • 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