Advertisement
matheus_monteiro

Fibonacci?

Sep 6th, 2022
653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. def isSquareResidue(x, p):
  2.     if x == 0 or pow(x, int((p - 1) / 2), p) == 1:
  3.         return True
  4.     return False
  5.  
  6. def isPerfectSquare(n, p):
  7.     r = (n % p) * (n % p) * 5
  8.     if isSquareResidue((r - 4) % p, p) or isSquareResidue((r + 4) % p, p):
  9.         return True
  10.     return False
  11.  
  12. n = int(input())
  13. lisOfPrimes = [x for x in range(100) if x > 1 and len([d for d in range(2, x) if x % d == 0]) == 0]
  14. isFib = [False for p in lisOfPrimes if isPerfectSquare(n, p) == False]
  15.  
  16. if len(isFib) > 0:
  17.     print('NAO')
  18. else:
  19.     print('SIM')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement