Skip to content

Commit

Permalink
Reto mouredev#21 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
guillepinto committed May 22, 2023
1 parent 8604b8c commit b863039
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import math

def is_prime(n:int):
if n>1:
for i in range(2,int(math.sqrt(n))+1):
if (n%i) == 0:
return False
return True
else:
return False

def primos_gemelos(rango:int):
primos=[]
gemelos=[]
for i in range(1,rango):
if is_prime(i):
primos.append(i)
for n,j in enumerate(primos):
if n<len(primos)-1:
if primos[n+1]-j==2:
tupla=(j,primos[n+1])
gemelos.append(tupla)
return gemelos

print(primos_gemelos(100))

0 comments on commit b863039

Please sign in to comment.