Advertisement
Guest User

Untitled

a guest
Jan 31st, 2022
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import random
  2. import os
  3. random.seed()
  4. from math import *
  5.  
  6.  
  7. def findNs(a, b):
  8. p = a*b
  9. i = int(floor((log(p)/2)-1))
  10. j = int(floor(log(p)*2))
  11. limit = ceil((p**0.5) / (floor(log(p)/2)-1))
  12. limit = ceil(limit**(1/(3**0.5)))
  13. s = ''
  14. ns = ''
  15. n = 0
  16. k = 0
  17. while i <= limit:
  18. j = int((int(floor(log(p))*2)**2)/2)
  19. while j >= 3:
  20. ns = str(p)+str(i)+(str(p)[0:-1])+str(j)
  21. n = int(ns)
  22. valA = (n%(p-1))%a
  23. valB = (n%(p-1))%b
  24. if valA == 0 or valA == 1 or valB == 0 or valB == 1:
  25. _ = input("found valA or valB that equals either 1 or 0")
  26. print(f"ns%a: {ns}, val: {valA}, ij: {i}, {j}")
  27. print(f"ns%b: {ns}, val: {valB}, ij: {i}, {j}")
  28. if (n%(p-1))%a == 0 or (n%(p-1))%a == 1 or (n%(p-1))%b == 0 or (n%(p-1))%a == 1:
  29. print(f"found ns value that works!, total iterations: {k}, ratio over a: {k/a}, ij: {i}, {j}")
  30. print(f"limit: {limit}")
  31. print(f"p: {p}, k: {k}")
  32. return i, j, n, limit
  33. else:
  34. j = j - 1
  35. k = k + 1
  36. i = i + 1
  37.  
  38. #else
  39. print("no exact match found. Returing None.")
  40. return None
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement