Last active
August 29, 2015 14:16
-
-
Save ejherran/eb568ccd24ddaf21ab3f to your computer and use it in GitHub Desktop.
Generador de números primos. Entrega el logaritmo natural, el logaritmo base 10 y el numero primo separados por comas; ideal para crear listas en formato csv.
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/env python | |
| # -*- coding: utf-8 -*- | |
| # | |
| # Use: python genPrimos.py > primos.csv | |
| # | |
| import math | |
| prim = [] | |
| def vPrim(num): | |
| res = True | |
| for n in prim: | |
| if (num % n ) == 0: | |
| res = False | |
| break | |
| return res | |
| i = 2 | |
| try: | |
| print "LN, LOG10, PRIMO" | |
| while(True): | |
| e = math.log(i) | |
| d = math.log10(i) | |
| if vPrim(i): | |
| prim.append(i) | |
| print str(e)+", "+str(d)+", "+str(i) | |
| i = i+1 | |
| except: | |
| print "Exit!." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment