youngorc
发表于 2020-2-23 10:06:08
import math
list1=
for i in range(101,201):
for j in range(2,int(math.sqrt(i))+2):
if i%j==0:
list1.remove(i)
break
print(list1)
Yedada
发表于 2020-2-25 21:27:21
for i in range(101, 201):
flag = True
for j in range(2, int(math.sqrt(i))+1):
if i % j == 0:
flag = False
break
if(flag):
print(i)
Yedada
发表于 2020-2-25 21:29:43
import math
count = 0
for i in range(101, 201):
flag = True
for j in range(2, int(math.sqrt(i)) + 1):
if i % j == 0:
flag = False
break
if flag:
count += 1
print(i)
# 个数
print(count)
嘿嘿嘿的黑子哥
发表于 2020-2-27 10:40:07
import math
def prime(number):
for i in range(2,int(math.sqrt(number))):
if number % i ==0:
return False
else:
return True
for i in range(100,201):
if prime(i):
print(i,end = " ")
海上飞鱼
发表于 2020-2-27 19:38:46
primes = []
for n in range(101,201):
for i in range(2,int(n**0.5)+1):
if n % i == 0:
break
else:
primes.append(n)
print(primes)
xiaofan1228
发表于 2020-2-29 20:36:57
#prime number
count = 0
list_all = []
for each_num in range(101,200):
#print(each_num)
list1 = []
for i in range(2, each_num-1):
if each_num % i == 0:
list1.append(i)
if len(list1) == 0:
list_all.append(each_num)
print("一共有素数%d个,分别是%s" %(len(list_all), list_all))
gzi
发表于 2020-3-3 11:38:46
a = 0
for i in range(101,201):
for j in range(2,i):
if i % j == 0:
a += 1
if a == 0:
print(i)
else:
a = 0
杜若左
发表于 2020-3-5 00:25:47
k=0
for i in range(101,201):
for j in range(2,i+1):
if (i%j==0):
break;
if i ==j :
print(i)
k=k+1
print("101到200一共有",k,"个素数 ")
菜鸡献丑
土二奇
发表于 2020-4-22 16:42:50
新手·ing 发表于 2017-3-27 19:45
@lumber2388779 @ooxx7788 @jerryxjr1220 @冬雪雪冬
来吧!新题目来了!
其实没必要开更号再加一,直接for iin range(2,m-1)就可以了吧,只不过这样会多循环几次,但是可读性会不会比较好点
尔东方
发表于 2020-4-27 18:14:05
import math
for i in range(101,201):
for j in range(2,int(math.sqrt(i)+1)):
if i%j==0:
break
else:
print(i,end=' ')
san1412
发表于 2020-5-9 13:07:45
num = 100
a_list = list(range(101,201))
for i in range(101,201):
for j in range(2,i):
if i % j == 0:
num -=1
a_list.remove(i)
break
print("101-200之间有%d个素数"%num)
print("所有素数:",a_list)
ForPorsche
发表于 2020-5-22 23:10:30
count = 0
for i in range(101, 201):
for j in range(2, i):
if i % j == 0:
break
else:
count += 1
print(i, end=' ')
print('\n有%d个素数.' % count)
今天的我更强了
发表于 2020-6-21 10:51:30
#def is_prime(n):
# temp=False
# for i in range(2,n):
# if n%i==0:
# temp=True
# return temp
#def mu(n):
# while n-1:
# if not is_prime(n):
# yield n
# n-=1
#count=0
#for i inmu(200):
# if i>100:
# count+=1
# print (i,end='')
#print(count)
#
鲨鱼辣椒1
发表于 2020-7-25 19:14:30
list1 = []
list2 = []
for i in range(101,201):
for t in range(2,int(i**0.5) + 1): # 这里因为i要把t的数除遍,所以每次能除尽,都会打印一个i。
if i % t == 0: # 这里不能用 != ,因为每个数都有除不尽的时候。
list1.append(i)
a = set(list(list1)) # set()创建一个无序不重复元素集
for j in range(101,201):
if j not in a:
list2.append(j)
print(list2)
想起飞吗
发表于 2020-9-15 10:29:48
count=0
for i in range(101,201):
for a in range(2,i):
if i % a == 0 :
count += 1
print(i)
break
print(count)
不知道可不可以,请大佬指正(break可以用在这里吗?)
谢啾啾
发表于 2020-10-28 16:27:12
自己鼓捣了半天,结果没有输出,哭哭
import math as m
prime_num = []
def is_primenum():
n = 101
while n <=200:
for i in range(2, int(m.sqrt(n))+1):
if n % i == 0:
return False
else:
prime_num.append(n)
n += 1
for each in prime_num:
print(each, end=' ')
print('共有%d个素数'% prime_num.len())
is_primenum()
zx122323216
发表于 2020-12-16 18:48:13
for i in range(101,201):
judge = 0
for a in range(2,i):
if i%a != 0:
continue
else:
judge += 1
if judge == 0:
print(i)
逃兵
发表于 2020-12-18 12:43:19
sushu=[]
for i in range(101,201):
temp=[]
for j in range(2,i):
if i% j == 0:
temp.append(i)
if temp==[]:
sushu.append(i)
print('总共有%d个素数'%len(sushu))
print('分别是')
for i in sushu:
print(i)