如何画求1-100之前所有孪生素数的流程图
急求!!!感谢大神指点:如何画求1-100之前所有孪生素数的流程图 画流程图有啥用,直接写代码好不 wp231957 发表于 2021-5-10 10:25画流程图有啥用,直接写代码好不
知道代码,或详细流程图的逻辑里不清楚了{:10_247:} temp1 = input("输入起始数")
temp2 = input("输入结束数")
num1 = int(temp1)
num2 = int(temp2)
list1 = []
for A in range(num1,num2):
for B in range(2,A):
if A % B == 0:
list1.append(A)
for C in range(num1,num2):
if C not in list1:
if C + 2 not in list1:
print((C , C + 2) ,end=";")
def isPrime(num):
if num < 2: return False
elif num == 2: return True
return not any()
twinPrime = [(j, i) for i in range(1, 101) for j in range(1, 101) if i-j == 2 and isPrime(i) and isPrime(j)]
print(*twinPrime)
(3, 5) (5, 7) (11, 13) (17, 19) (29, 31) (41, 43) (59, 61) (71, 73)
页:
[1]