Advertisement
sentique

Untitled

Nov 7th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import math
  2. def is_prime(n):
  3. if n % 2 == 0 and n > 2:
  4. return False
  5. for i in range(3, int(math.sqrt(n)) + 1, 2):
  6. if n % i == 0:
  7. return False
  8. return True
  9.  
  10. def is_prime2(n):
  11. if 2**(n-1) % n == 1 or 3**(n-1) % n == 1 or 5**(n-1) % n == 1:
  12. return True
  13. else:
  14. return False
  15.  
  16. n = int(input())
  17. a = 0
  18. for i in range(1,n+1):
  19. if is_prime(i) == False and is_prime2(i) == True:
  20. a += 1
  21. print(a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement