Message367736
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 |
|
Date |
User |
Action |
Args |
2020-04-30 05:16:25 | b_ICT | set | recipients:
+ b_ICT |
2020-04-30 05:16:25 | b_ICT | set | messageid: <1588223785.65.0.318875851427.issue40446@roundup.psfhosted.org> |
2020-04-30 05:16:25 | b_ICT | link | issue40446 messages |
2020-04-30 05:16:25 | b_ICT | create | |
|