This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients amaury.forgeotdarc, belopolsky, mark.dickinson
Date 2008-04-25.20:57:43
SpamBayes Score 0.3820637
Marked as misclassified No
Message-id <d38f5330804251357h10b226e7mbade6fc6661fab73@mail.gmail.com>
In-reply-to <1209155856.65.0.228224379393.issue2690@psf.upfronthosting.co.za>
Content
On Fri, Apr 25, 2008 at 4:37 PM, Mark Dickinson <report@bugs.python.org> wrote:
..
>  for i in range(1, p):
>     if (i_is_a_nonresidue_modulo_p):
>         break
>
>  Here p might be a 200-digit prime number, and the situation is that half
>  the integers between 1 and p-1 are 'quadratic residues', while the other
>  half are 'quadratic nonresidues';  in practice the residues and
>  nonresidues are mixed up fairly well, so the first nonresidue shows up
>  pretty quickly, but there's no known small upper bound on when the first
>  nonresidue appears.

Hmm, AFAIKT there is always at least one non-residue between 1 and p
and therefore you can just write

for i in itertools.count(1):
    if (i_is_a_nonresidue_modulo_p):
         break

maybe with an additional check for p > 1.
History
Date User Action Args
2008-04-25 20:57:46belopolskysetspambayes_score: 0.382064 -> 0.3820637
recipients: + belopolsky, amaury.forgeotdarc, mark.dickinson
2008-04-25 20:57:44belopolskylinkissue2690 messages
2008-04-25 20:57:43belopolskycreate