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 b_ICT
Recipients b_ICT
Date 2020-04-30.05:13:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588223600.07.0.719223766764.issue40446@roundup.psfhosted.org>
In-reply-to
Content
Hi, I was calculating Legendre coefficients, and quadratic residues and encountered what I believe to be a bug while using this code: 

for a in range (5):
        exp=int((p-1)/2)
        x=pow(a,exp,p)
        print(x)

If p is an odd prime, then x can have three values [-1,0,-1] - where "-1" refers to p-1. The code works well for reasonably small primes (like 9973). But with big primes(see below), python 3.7 spits out gibberish. Same code in python 2.7 works well.

The problem in python 3.7 can be avoided if exp is defined thusly :  
exp=(p-1)//2

Here is the prime I tried it on : 
p = 101524035174539890485408575671085261788758965189060164484385690801466167356667036677932998889725476582421738788500738738503134356158197247473850273565349249573867251280253564698939768700489401960767007716413932851838937641880157263936985954881657889497583485535527613578457628399173971810541670838543309159139
History
Date User Action Args
2020-04-30 05:13:20b_ICTsetrecipients: + b_ICT
2020-04-30 05:13:20b_ICTsetmessageid: <1588223600.07.0.719223766764.issue40446@roundup.psfhosted.org>
2020-04-30 05:13:20b_ICTlinkissue40446 messages
2020-04-30 05:13:19b_ICTcreate