home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!darwin.sura.net!mlb.semi.harris.com!uflorida!mailer.cc.fsu.edu!fsu1.cc.fsu.edu!rose
- From: rose@fsu1.cc.fsu.edu (Kermit Rose)
- Newsgroups: sci.math
- Subject: Re: Quadratic Residue Question
- Message-ID: <1992Jul18.122729.26174@mailer.cc.fsu.edu>
- Date: 23 Jul 92 04:29:18 GMT
- References: <1992Jul17.185526.26121@leela.cs.orst.edu> <1992Jul17.210332.2105@cs.umn.edu>
- Reply-To: rose@fsu1.cc.fsu.edu
- Organization: Florida State University
- Lines: 47
- News-Software: VAX/VMS VNEWS 1.3-4
-
- In article <1992Jul17.210332.2105@cs.umn.edu>, pires@cs.umn.edu (Luiz S. Pires) writes...
- >
- > ....
- >
- > Given an arbitrary number a and an odd prime p, I am trying to write a
- > subroutine that decides whether a is a quadratic residue mod p.
- >
- > ....
-
- > For example, if we have, say, a=31123 and p=45667, then I am not clear on
- > how to proceed. I thought of using Euler's lemma (or whatever it is called)
- > and calculate a^((p-1)/2) (mod p). That, however, would seem to have very poor
- > worst case performance.
- >
- > Does anyone have an efficient algorithm for determining this? Am I missing
- > something obvious here? Any help would be most welcome!
- >
- > Thanks in advance.
- >
- > Luiz.
- > (pires@cs.umn.edu)
-
- Actually, you can calculate a(([p-1]/2) (mod p) very efficiently. Example,
-
- a^3 = a^2 a^1
- a^4= (a^2)^2
- a^5 = (a^2)^2 a^1
- a^6 = ( (a^2 a^1) )^2
- a^7 = ( (a^2 a^1) )^2 a^1
-
- etc.
- simply think of k = [p-1]/2 in base 2.
-
- k = a_m 2^m + a_(m-1) 2 ^(m-1) + ... + a_1 2 + a_0
-
- k = ((((( .... a_m 2+a_[m-1] )2 +... )2 + a_1 2)+ a_0
-
- b_0 = b^k
- b_m = b^a_m
- b_[m-1] = b_m^2 b^a_m-1
- ..
- b_1 = b_2 ^2 b^a_1
- b_0 = b_1 ^2 b^a_0
-
- rose@fsu1.cc.fsu.edu To be sure I see your response, use e-mail.
- -----------------------------------------------------------------------
- Be of good cheer, for it is much more fun than being depressed.
-