Skip to content

Instantly share code, notes, and snippets.

@ejherran
Last active August 29, 2015 14:16
Show Gist options
  • Save ejherran/eb568ccd24ddaf21ab3f to your computer and use it in GitHub Desktop.
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.
#!/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