foxiangzun
发表于 2019-1-3 20:22:16
def getNum() :
numlist = []
for i in range(101, 201) :
flag = 0
for j in range(2, i + 1) :
if i % j == 0 :
flag += 1
if flag < 2 :
numlist.append(i)
print('101 到 200 之间的质数共有:', len(numlist), ' 个')
for i in numlist :
print(i, end=', ')
getNum()
xxt
发表于 2019-1-16 20:32:49
import math
for i in range(101, 201):
q = int(math.sqrt(i))
for j in range(2, q+1):
if i % j == 0:
break
if j == q:
print(i)
冷_月
发表于 2019-1-22 22:54:07
本帖最后由 冷_月 于 2019-1-22 22:57 编辑
from math import sqrt
a = []
for n in range(101,201):
for i in range(2,int(sqrt(n)) +1):
if n % i == 0:
a = n
if a != n:
print(n)
anticheung
发表于 2019-1-24 15:54:36
本帖最后由 anticheung 于 2019-1-24 15:56 编辑
numlis = []
data_n = 0
for num in xrange(101 , 201):
numlis.append(num)
for i in xrange(2,num):
if num%i == 0:
numlis.remove(num)
break
else:
pass
for nums in numlis:
data_n += 1
print nums
print 'Number of data:%d' % data_n
北城以北灬
发表于 2019-2-22 14:14:59
from math import sqrt
sum = 0
for n in range(101, 200, 2):
leap = 0
for i in range(3, int(sqrt(n))+1, 2):
if n % i == 0:
leap = 1
break
if leap == 0:
print(n)
sum += 1
print("The total is", sum)
Sneakerjj
发表于 2019-3-11 13:39:51
from math import sqrt
ss = ]
print(ss)
print(len(ss))
lwy520
发表于 2019-3-12 18:20:23
sushu=[]
for i in range(101,200):
for j in range(2,int(i**0.5)+1):
if i % j == 0:
break
else:
if j==int(i**0.5):
sushu.append(i)
print(sushu)
小强森
发表于 2019-4-2 15:36:56
#新手小弟见笑了
for a in range(101,201):
b=2
c=0
while b<a:
if a%b==0:
c+=1
b+=1
if c==0:
print(a)
zx122323216
发表于 2019-4-10 11:32:37
L = []
biaoji = 0
for each in range(101,201):
for i in range(2,each):
if each%i != 0:
biaoji = 1
continue
else:
biaoji = 0
break
if biaoji == 1:
L.append(each)
print(L)
YOKAI
发表于 2019-4-15 20:26:21
看到大佬们打那么多代码,突然感觉自己的是不是不对啊?
>>> for i in range(101,201):
if i%2 != 0:
print (i)
yu123py
发表于 2019-4-26 18:22:15
好像是这样:
def prime(n):
if n == 1:
return False
if n == 2:
return True
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
s = 0
for j in range(101, 200):
if prime(j):
s+= 1
print(j, end=" ")
print()
print(s)
后飞的笨鸟
发表于 2019-4-26 18:50:21
def isPrime( x ):
i = 2
while i*i <= x:
if x % i == 0: return False
i+= 1
return True
result =
print(result)
山岂乎不在高
发表于 2019-7-7 19:09:22
import math
def prime(start,end):
for i in range(start,end):
d = int(math.sqrt(i))+1
for j in range(2,d+1):
if not(i % j):
break
if j == d:
yield i
if __name__ == "__main__":
lista =
print(lista)
jinlovelive
发表于 2019-7-7 20:21:17
from math import sqrt
for i in range(101,201):
count = 0
t = int(sqrt(i))
for j in range(2,t+1):
if i%j == 0:
count = 0
break
else:
count += 1
if count > 0:
print(i)
一条乐
发表于 2019-8-9 10:00:15
import math
flag = 1
for i in range(101,201):
for j in range(2,int(math.sqrt(i))+1):
if i % j == 0:
flag = 0
break
if flag == 1:
print("%d" % i)
flag = 1
九五二七
发表于 2019-10-31 21:13:26
>>> for i in range(101,201):
for j in (2,int(math.sqrt(i))+1):
if i%j==0:
break
else:
print(i)
九五二七
发表于 2019-11-4 20:35:48
> for i in range(101,201):
for j in range(2,i):
if i%j==0:
break
else:
print(i)
Jung
发表于 2019-11-22 10:49:40
import math
def fun8():
L = []
for i in range(101,200):
for N in range(2,int(math.sqrt(i))+1):
if((i%N)==0):
break
else:
L.append(i)
break
print(L,len(L))
ka233siji
发表于 2020-1-16 11:29:43
本帖最后由 ka233siji 于 2020-1-16 11:31 编辑
count,bre = 0,0
list =
for i in range(101,200) :
for j in list :
if not i%j :
bre = 1
break
if not bre :
print(i,end=' ')
count+=1
bre = 0
print('\ntotal is %d'%count)
运行结果
101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199
total is 21
ouyunfu
发表于 2020-2-12 05:35:32
def is_prime(n):
if n==2 or n==3:
return True
else:
for i in range (2,int(n**0.5)+1):
if n%i==0:
return False
else:
return True
count,L=0,[]
for i in range(101,201):
if is_prime(i):
count+=1
L.append(i)
print('101-200之间共有%d个素数'%count)
print('分别是:')
print(L)