Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import os
- random.seed()
- from math import *
- def findNs(a, b):
- p = a*b
- i = int(floor((log(p)/2)-1))
- j = int(floor(log(p)*2))
- limit = ceil((p**0.5) / (floor(log(p)/2)-1))
- limit = ceil(limit**(1/(3**0.5)))
- s = ''
- ns = ''
- n = 0
- k = 0
- while i <= limit:
- j = int((int(floor(log(p))*2)**2)/2)
- while j >= 3:
- ns = str(p)+str(i)+(str(p)[0:-1])+str(j)
- n = int(ns)
- valA = (n%(p-1))%a
- valB = (n%(p-1))%b
- if valA == 0 or valA == 1 or valB == 0 or valB == 1:
- _ = input("found valA or valB that equals either 1 or 0")
- print(f"ns%a: {ns}, val: {valA}, ij: {i}, {j}")
- print(f"ns%b: {ns}, val: {valB}, ij: {i}, {j}")
- if (n%(p-1))%a == 0 or (n%(p-1))%a == 1 or (n%(p-1))%b == 0 or (n%(p-1))%a == 1:
- print(f"found ns value that works!, total iterations: {k}, ratio over a: {k/a}, ij: {i}, {j}")
- print(f"limit: {limit}")
- print(f"p: {p}, k: {k}")
- return i, j, n, limit
- else:
- j = j - 1
- k = k + 1
- i = i + 1
- #else
- print("no exact match found. Returing None.")
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement