Advertisement
tulrich

lucas_lehmer_test

Apr 19th, 2021
1,126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. def lucas_lehmer_seq(p):
  2.     s = 4
  3.     m = 2**p - 1
  4.     res = list()
  5.     for i in range(p-2):
  6.         s = ((s*s)-2)%m
  7.         res.append(s)
  8.     return res
  9.  
  10. def test_LL(p):
  11.     m = 2**p - 1
  12.     ll = lucas_lehmer_seq(m)
  13.     res = (0,0)
  14.     if ll[p-2] ==0:
  15.         res = (p,1)
  16.     else:
  17.         res = (p,0)
  18.     return res
  19.  
  20. print(test_LL(17))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement