Home > Backend Development > Python Tutorial > python实现挑选出来100以内的质数

python实现挑选出来100以内的质数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 11:23:16
Original
1790 people have browsed it

这里给大家分享的是使用python实现将100以内的质数挑选出来

代码非常简单,就不多废话了。

"""
使用filter将100以内的质数挑选出来
"""
 
# coding = utf-8
import math
def func_get_prime(n):
  return filter(lambda x: not [x%i for i in range(2, int(math.sqrt(x))+1) if x%i ==0], range(2,n+1))
   
print func_get_prime(100)
Copy after login

以上所述就是本文的全部内容了,希望大家能够喜欢。

请您花一点时间将文章分享给您的朋友或者留下评论。我们将会由衷感谢您的支持!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template