Created
July 14, 2011 13:51
-
-
Save Visgean/1082491 to your computer and use it in GitHub Desktop.
Prime numbers generator
This file contains hidden or 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/python | |
| # -*- coding: UTF-8 -*- | |
| # Prime numbers | |
| # @author: Visgean Skeloru | |
| # email: <visgean@gmail.com> | |
| # jabber: <visgean@jabber.org> | |
| # github: http://github.com/Visgean | |
| numbers = range(3, int(raw_input("Max value: ")) + 1, 2) | |
| print 2 | |
| for n in numbers: | |
| print n | |
| maxMultiple = numbers[-1] / n | |
| while maxMultiple > 1: | |
| try: | |
| numbers.remove(n * maxMultiple) | |
| except: | |
| pass | |
| maxMultiple -= 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment