Skip to content

Instantly share code, notes, and snippets.

@andreuinyu
Last active January 18, 2016 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreuinyu/77e77d72ab18bd1b1324 to your computer and use it in GitHub Desktop.
Save andreuinyu/77e77d72ab18bd1b1324 to your computer and use it in GitHub Desktop.
from math import sqrt
N = 1997
A = 59
B = 23
coords = []
for x in range(N):
temp = (pow(x, 3, N) + A*x + B) % N
while (temp < 0):
temp += N
for i in range(N):
if (i*i % N == temp):
punt1 = [x, i]
punt2 = [x, -i]
while (punt2[1] < 0):
punt2[1] += N
if (punt1 not in coords):
coords.append(punt1)
if (punt1 not in coords):
coords.append(punt2)
print(coords)
print("cardinalitat de y^2 = x^3 +",A,"x +",B," sobre Z/",N,"Z =", len(coords)+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment