# python123去除整数列表中的素数,【Python】Python_learning10_1：Python中的素数筛选（方法一）...

~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~

Examination Problem

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Analysis

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Program

Program1

"""

File: example12.py:

Time:Created on 2016-09-02 21:31:11

Author: Sure

"""

#!/usr/bin/python

# -*- coding: UTF-8 -*-

#程序源代码：

import time

print("当前时间：")

print ( time.strftime( ' %Y-%m-%d %H:%M:%S',time.localtime(time.time()) ) )

P=0 #P means prime number

leap = 1 #leap means jump 1 per time

from math import sqrt

from sys import stdout

for m in range(101,201):

k = int(sqrt(m + 1))

for i in range(2,k+1):

if m % i == 0:

leap = 0

break

if leap == 1:

print("第%3d 个素数为:%12d" %(P,m))

P += 1

if P % 10 == 0:

print('')

leap = 1

print('the total is %d' %P)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Results

2016-09-02 22:01:29

the total is 21

03-28 1万+

03-08 237
07-03 996
01-12 1373

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助