1013 数素数
输入样例:
5 27
输出样例:
11 13 17 19 23 29 31 37 41 43
47 53 59 61 67 71 73 79 83 89
97 101 103
代码如下
import math
def prime(n):
if n==2:
return True
else:
half = math.ceil(math.sqrt(n))
count = 1
for i in range(1,half+1):
if n%i==0:
count+=1
if count==2 :
return True
else:
return False
m,n = map(int,input().split(' '))
num = 0
prime_count = []
a=2
while num != n:
if prime(a):
num+=1
prime_count.append(a)
a+=1
prime_count = prime_count[m-1:]
count = 0
row = 0
for i in prime_count:
if count!=9 and (row*10+count)!= len(prime_count)-1:
print(i,end=' ')
count+=1
else:
print(i)
count=0
row +=1