Skip to content

Instantly share code, notes, and snippets.

@bbeckercontato
Last active January 31, 2016 12:25
Show Gist options
  • Save bbeckercontato/8e51422511da08aa4884 to your computer and use it in GitHub Desktop.
Save bbeckercontato/8e51422511da08aa4884 to your computer and use it in GitHub Desktop.
gerador de numeros primos em phi(42*n) Teoria matemática de Bruno Becker.
limite = int(input("Digite limite: "))
contador = 0
base2=[]
primos=[]
base = [ 1, 5, 11, 13, 17, 19, 23, 25, 29, 31, 37, 41]
pa=[]
import time
t0 = time.time()
arq = open("Primos.html", "w")
while limite > base[-1]:
for b in base:
if b%5 != 0:
base2.append(b)
base = [s+42 for s in base]
base2.remove(1)
limite = base2[-1]
for r in base2:
x = r
y = r
while x <= limite and x <= y*y:
x=x+y*4
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*6
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*2
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*4
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*2
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*4
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*2
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*4
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*2
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*6
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*4
if x <= limite and x <= y*y:
pa.append(x)
else:
break
x=x+y*2
if x <= limite and x <= y*y:
pa.append(x)
else:
break
base2.append(2)
base2.append(3)
base2.append(5)
base2.append(7)
arq.write(str(sorted(set(base2) - set(pa))))
arq.close()
del(pa)
del(base2)
tf = time.time()
print("\n")
print("Tempo executado: ",tf - t0)
print("\n")
print("\n")
print("\n")
print("\n")
print("Foi gerado lista em arquivo de texto no local do programa")
print("\n")
raw_input("Pressione ENTER para SAIR")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment