Basic ICT Repairs <basic.ict.repa...@gmail.com> added the comment:

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

----------
type:  -> behavior
versions: +Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40446>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to