inverseli
发表于 2018-3-7 18:42:33
def prime(num): # 判断质数函数
book = 0 #标记
for i in range(2,num):
if num%i == 0:
book = 1
break
if book == 0:
return num
for i in range(2,101):
num = prime(i)
if num != None:
temp = prime(num*10+1)
if temp != None:
print(num)
ouyunfu
发表于 2018-3-7 18:46:26
def prime_judge(num):
if num > 1:
for i in range(2, num):
if (num % i) == 0:
return False
else:
return True
for j in range(2,100):
if prime_judge(j) and prime_judge(j*10+1):
print(j)
newbieofnewbie
发表于 2018-3-7 19:16:15
def min(a):
for i in range(2,int(a ** 0.5)+1):
if a % i == 0 :
return 0
return 1
for j in range(2,100):
if min(j):
temp=j*10+1
if min(temp):
print("%d"% j)
曼洛尼康帝
发表于 2018-3-7 19:27:58
def prime(number): #判断质数
gole = 0
for i in range(1,number):
if((number % i) == 0):
gole += 1
if(gole == 1):
return 1
else:
return 0
for i in range(100):
if(prime(i)):
if (prime(10*i+1)): #分别判断质数
print("%d"%i)
瞬秒爆加速
发表于 2018-3-7 19:45:30
def n(n):
a = {i for i in n if all(i%ii for ii in range(2,int(i**0.5)+1))}
b = {i*10+1 for i in a}
#求交集
return b&a
if __name__=="__main__":
print(n(range(2,100)))
JessiFly
发表于 2018-3-7 19:55:05
def isprime(num):
if num ==2:
return True
elif num%2 == 0 or num == 1:
return False
else:
i = 2
while i <= num ** 0.5:
if num%i == 0:
return False
else:
i += 1
return True
for i in range(3,100,2):
if isprime(i):
temp = i*10 + 1
if isprime(temp):
print(i,end = ' ')
shigure_takimi
发表于 2018-3-7 20:08:21
def isPrime(n):
if n < 2:
return False
else:
for i in range(2, int(n**0.5)+1):
if n % i == 0:
return False
else:
return True
for i in range(1,100):
a = i * 10 + 1
if isPrime(i) and isPrime(a):
print(i, '-->', a)
##结果:3, 7, 13, 19, 31, 43, 97
## 3 --> 31
## 7 --> 71
## 13 --> 131
## 19 --> 191
## 31 --> 311
## 43 --> 431
## 97 --> 971
8306最硬
发表于 2018-3-7 20:12:01
from math import sqrt
def isPrime(n):
for i in range(2, int( sqrt(n) ) + 1):
if n % i == 0:
return False
return True
for i in range(2, 100):
if isPrime(i):
if isPrime(i * 10 + 1):
print(i)
t6am3
发表于 2018-3-7 20:31:30
def judge(a):
for i in range(2,a):
if a % i == 0:
return 0
return 1
for i in range(2,100):
if judge(i) and judge(10*i+1):
print(i)
#提出一个建议:每日一题能不能出一道普通版的再出一道难一点的。。。想多练习练习
fc1735
发表于 2018-3-7 20:59:31
def q159():
p=*1024
for i in range(2,32):
if not p:
for j in range(2*i,1024,i):
p+=1
for i in range(2,100):
if not (p or p):
print(i,'满足条件')
3, 7, 13, 19, 31, 43, 97
PYTHON90小菜鸟
发表于 2018-3-7 21:34:57
def prime(number):
temp = 2
while temp < number:
if (number % temp) == 0:
return False
temp += 1
return True
n = 2
while n < 100:
if prime(n) == True:
s = n * 10 + 1
if prime(s) == True:
print(n)
n += 1
天圆突破
发表于 2018-3-7 22:20:23
本帖最后由 天圆突破 于 2018-3-8 10:30 编辑
def zhishu(n):
lst =
for i in range(3, n+1, 2):
for j in range(3, int(i/2)+1):
if not(i%j):break
else:lst.append(i)
return lst
if __name__ == '__main__':
print()
qwc3000
发表于 2018-3-7 22:30:54
zhishu_list=
for num in zhishu_list:
if (num*10%6==0)or((num*10+2)%6==0):
print("%d *10 +1 = %d" %(num,num*10+1))
wyp02033
发表于 2018-3-7 22:42:10
from math import sqrt
def is_prime(n):
if n == 0 or n == 1:
return False
elif n == 2 or n == 3:
return True
else:
for i in range(2, int(sqrt(n))+1):
if n % i == 0:
return False
return True
def generate_special_primes(primes):
special_primes = []
for each in primes:
num = each * 10 + 1
if is_prime(num):
special_primes.append(each)
return special_primes
if __name__ == '__main__':
primes = []
for i in range(100):
if is_prime(i):
primes.append(i)
print(generate_special_primes(primes))
125zl
发表于 2018-3-7 23:30:53
本帖最后由 125zl 于 2018-3-8 15:06 编辑
list = []
for i in range(2,1001):
s = 0
for j in range(2,i):
if i % j == 0:
s += 1
if s == 0:
list.append(i)
for i in list:
if 10 * i + 1 in list:
print(i)
所向故往
发表于 2018-3-7 23:37:14
import math
def func_get_prime(n):
L = list(filter(lambda x: not , range(2,n+1)))
L_1 = []
for i in L:
L_1.append(int(i)*10+1)
return filter(lambda y: not , L_1)
L_2 = []
for i in list(func_get_prime(100)):
L_2.append((int(i)-1)/10)
print(L_2)
Andy0214
发表于 2018-3-8 09:27:42
质数*10+1得到的质数还是100以内的质数吗?还是所有的质数都行
Andy0214
发表于 2018-3-8 09:29:21
def prime(n):
num = []
for i in range(2,n):
fg = 0
for j in range(2,i-1):
if i%j == 0:
fg = 1
break
if fg == 0:
# print (i)
num.append(i)
return num
def main():
k = prime(1000)
for g ink:
if (g*10+1) in k:
print(g)
if __name__ == "__main__":
main()
dunhee
发表于 2018-3-8 09:38:37
def isPrime(n):
for i in range(2, int(n**0.5)+1):
if n%i == 0: return False
return n >= 2
def f(n):
return
print(f(100))
__糖分
发表于 2018-3-8 10:01:33