fantho69

p_q_prime_solver_q=(p^3-p-13)_frac_(109(3p+64)).py

Nov 12th, 2025 (edited)
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | Science | 0 0
  1. # Program to search p, q primes so that
  2. # q = (p**3-p-13)/(109*(3*p+64))
  3. # Python3 programs to do Miller-Rabin primality test
  4. P=15000
  5. import random
  6. def power(x, y, p):
  7.     res = 1
  8.     x = x % p
  9.     while (y > 0):  
  10.         if (y & 1):
  11.             res = (res * x) % p
  12.         y = y>>1; # y = y/2
  13.         x = (x * x) % p
  14.     return res
  15. def miillerTest(d, n):  
  16.     a = 2 + random.randint(1, n - 4)
  17.     x = power(a, d, n)
  18.     if (x == 1 or x == n - 1):
  19.         return True;
  20.     while (d != n - 1):
  21.         x = (x * x) % n
  22.         d *= 2
  23.         if (x == 1):
  24.             return False
  25.         if (x == n - 1):
  26.             return True
  27.     return False.
  28. def prime( n, k):  
  29.     if (n <= 1 or n == 4):
  30.         return False
  31.     if (n <= 3):
  32.         return True
  33.     d = n - 1;
  34.     while (d % 2 == 0):
  35.         d //= 2
  36.     for i in range(k):
  37.         if (miillerTest(d, n) == False):
  38.             return False
  39.     return True
  40. # Driver Code
  41. # Number of iterations
  42. k = 4
  43. for p in range(2,P):
  44.     if((p**3-p-13)%(109*(3*p+64))==0):
  45.         if(prime(p,k) and prime((p**3-p-13)//(109*(3*p+64)),k)):
  46.            print(p,(p**3-p-13)//(109*(3*p+64)))
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment