我不打表,我查别人的表,^_^
因为要访问网络,用C++也不是很好整,这里用python了
sh-5.1$ ls
main.py
sh-5.1$ cat main.py
#!/usr/bin/env python
#coding=utf-8
import requests, re
import time
def prime(n: int) -> bool:
url = r'https://zh.numberempire.com/primenumbers.php'
data = {'number': f'{n}'}
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1500.56 Safari/537.36'}
response = requests.post(url, headers = headers, data = data)
pattern = rf'数字.*?{n}.*?不是质数'
if re.search(pattern, response.text): return False
pattern = rf'数字.*?{n}.*?是质数'
if re.search(pattern, response.text): return True
raise "未查询到结果"
time.sleep(0.5)
print(12, prime(12))
time.sleep(0.5)
print(13, prime(13))
time.sleep(0.5)
print(0xffffffffffffffff, prime(0xffffffffffffffff))
time.sleep(0.5)
print(0x1ffffffffffffff0, prime(0x1ffffffffffffff0))
sh-5.1$ ./main.py
12 False
13 True
18446744073709551615 False
2305843009213693936 False
sh-5.1$
|