SHARE
TWEET

prim root

a guest Nov 3rd, 2016 169 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def primitive_root(prime):
  2.     num_to_check = 0
  3.     primitive_roots = []
  4.     for each in range(1, prime):
  5.         num_to_check += 1
  6.         candidate_prim_roots = []
  7.         for i in range(1, prime):
  8.             modulus = (num_to_check ** i) % prime
  9.             candidate_prim_roots.append(modulus)
  10.             cleanedup_candidate_prim_roots = set(candidate_prim_roots)
  11.             if len(cleanedup_candidate_prim_roots) == len(range(1, prime)):
  12.                 primitive_roots.append(num_to_check)
  13.     return primitive_roots
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top