Skip to content

Commit

Permalink
Merge pull request #3531 from Majinka10/main
Browse files Browse the repository at this point in the history
Reto #20 - Python & Reto #21 - Python
  • Loading branch information
Roswell468 authored May 23, 2023
2 parents 0b42af3 + b863039 commit 9d0bde6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Retos/Reto #20 - LA TRIFUERZA [Media]/python/majinka10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def primero(n:int):
for i in range(n):
print(' ' * (2*n-i-1) + '*' * (2*i+1))

def segundo(n:int):
for i in range(n):
print(' ' * (n-i-1) + '*' * (2*i+1) + ' ' * (2*n- (i*2) -1) + '*' * (2*i+1))

def trifuerza(n:int):
primero(n)
segundo(n)

trifuerza(5)
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 9d0bde6

Please sign in to comment.