Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def is_prime(n):
- if n % 2 == 0 and n > 2:
- return False
- for i in range(3, int(math.sqrt(n)) + 1, 2):
- if n % i == 0:
- return False
- return True
- def is_prime2(n):
- if 2**(n-1) % n == 1 or 3**(n-1) % n == 1 or 5**(n-1) % n == 1:
- return True
- else:
- return False
- n = int(input())
- a = 0
- for i in range(1,n+1):
- if is_prime(i) == False and is_prime2(i) == True:
- a += 1
- print(a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement