Fuçando na web achei um código que quero melhorar com a ajuda dos nobres leitores e saber se ele se enquadra na definição do Crivo de Eratóstens. Segue o código:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# # -*- coding: UTF-8 -*- | |
# Criado em:Seg 12/Abr/2010 hs 15:48 | |
# Last Change: Seg 12/Abr/2010 hs 15:48 | |
# vim:ft=python:nolist:nu: | |
# Instituicao: none | |
# Proposito do script: calcular números primos | |
# Autor: Sérgio Luiz Araújo Silva | |
# site: http://vivaotux.blogspot.com | |
# Referências: http://pipeless.blogspot.com/2008/09/o-crivo-de-eratstenes-em-python.html | |
# download: http://gist.github.com/363882#file_prime.py | |
print "calculo de numeros primos" | |
max = int(raw_input("Digite o limitie :")) | |
print [x for x in range(2,max) if not [t for t in range(2,int(x**1/2)) if not x%t]] | |
Veja este post.