-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3531 from Majinka10/main
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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) |
25 changes: 25 additions & 0 deletions
25
Retos/Reto #21 - NÚMEROS PRIMOS GEMELOS [Media]/python/majinka10.py
This file contains 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
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)) |