SHARE
TWEET

Untitled

a guest Mar 19th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def jacobi(a, n):
  2.         assert(n > a > 0 and n%2 == 1)
  3.         t = 1
  4.         while a != 0:
  5.             while a % 2 == 0:
  6.                 a /= 2
  7.                 r = n % 8
  8.                 if r == 3 or r == 5:
  9.                     t = -t
  10.             a, n = n, a
  11.             if a % 4 == n % 4 == 3:
  12.                 t = -t
  13.             a %= n
  14.         if n == 1:
  15.             return t
  16.         else:
  17.             return 0
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