1 n = int(input('Input an integer: ')) 2 if n == 2: 3 print('Yes') 4 elif n % 2 == 0: 5 print('No') 6 else: 7 m = n % 6 8 #因为大于5的素数必然出现在6的倍数两侧 9 #6x+2,6x+3,6x+4肯定不是素数 10 if m != 1 and m != 5: 11 print('No') 12 else: 13 for i in range(3, int(n**0.5) + 1, 2): 14 if n % i == 0: 15 print('No') 16 break 17 else: 18 print('Yes') 19