##第七种
a = (" ".join("%s" % x for x in range(2, 100) if not [
y for y in range(2, x) if x % y == 0])).split()
list1 = []
for item in (a):
list1.append(int(item))
print(list1)
##第八种
def isprime(i):
j = 2
while j <= i/2:
if i % j == 0:
return False
j += 1
return True
def PrintPrinme(numberOfPrime):
number_Of_Primes = 23
count = 0
i = 2
while count < numberOfPrime:
if isprime(i):
count += 1
print(i, end=" ")
i += 1
def main():
PrintPrinme(25)
main()
?
##第九种
for i in range(2, 100):
sushu = 0
for j in range(2, i):
if i % j == 0:
sushu += 1
if sushu == 0:
print(i, end=" ")
##第十种
from sys import stdout
from math import sqrt
shu = 0
su = 1
for m in range(2, 100):
k = int(sqrt(m + 1))
for i in range(2, k + 1):
if m % i == 0:
su = 0
break
if su == 1:
print(m, end=' ')
shu += 1
if shu % 10 == 0:
print('')
su = 1
?
##第十一种
import math
a = []
n = int(100)
for i in range(0, n+1, 1):
a.append(1)
for i in range(0, n+1, 1):
if i % 2 == 0:
a[i] = 0
for i in range(3, int(math.sqrt(n))+1, 2):
if(a[i] == 1):
for j in range(i+i, n+1, i):
a[j] = 0
a[2] = 1
for i in range(2, n+1, 1):
if a[i] == 1:
print(i, end=" ")
##第十二种
import math
sushu= [2, 3]
for i in range(5, 101):
for j in range(2, int(math.sqrt(i))+1):
if i % j == 0:
break
else:
sushu.append(i)
print(" ".join(map(str, sushu)))
?
##第十三种
import math
i = 2
while i < 101:
j = 2
flag_1 = True
flag_2 = 1
while j < int(math.sqrt(i)+1):
flag = False
flag_2 = 1
while i%j==0 and flag_2:
flag = True
flag_2 = 0
flag_2 = 1
while flag and flag_2:
flag_1 = False
flag_2 = 0
j += 1
while flag_1 and flag_2:
print(i,end=' ')
flag_2 = 0
i += 1
?
##第十四种
def test(sushu):
list = []
i = sushu - 1
while i > 1:
if sushu % i == 0:
list.append(i)
i -= 1
if len(list) == 0 and sushu != 1:
print(sushu, end=' ')
def primeNUM2(min, max):
j = min
while j < max:
test(j)
j += 1
print('')
primeNUM2(1, 100)
?
##第十五种
import math
a = 1
b = 100
c = []
count = 0
for sushu in range(a, b+1):
if sushu > 1:
for i in range(2, sushu):
if (sushu % i) == 0:
break
else:
c.append(sushu)
print(c)
##第十六种
def Prime(i):
if i == 2:
return 2
for a in range(2, i):
if i % a == 0:
break
if a == i - 1:
return i
def Primes(n, m):
li = []
for i in range(n, m):
if Prime(i) != None:
li.append(Prime(i))
return li
n = 1
m = 100
print(Primes(n, m))
##第十七种
sushu = 2
while(sushu< 100):
b = 2
while(b <= (sushu/b)):
if (sushu % b == 0):
break
b = b + 1
if (b > sushu/b):
print(sushu, end=" ")
sushu = sushu + 1
?
|