This file contains hidden or 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
function obtenerNumerosPrimos(n) | |
{ | |
const primos = []; | |
const esPrimo = new Array(n + 1).fill(true); | |
esPrimo[0] = esPrimo[1] = false; | |
let p = 2; | |
while (p * p <= n) | |
{ | |
if (esPrimo[p]) |
This file contains hidden or 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
function esPrimo(numero) | |
{ | |
if (numero <= 1) | |
{ | |
return false; | |
} | |
for (let i = 2; i <= Math.sqrt(numero); i++) | |
{ | |
if (numero % i === 0) { | |
return false; |
This file contains hidden or 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
using System; | |
class Program | |
{ | |
static void Main() | |
{ | |
// Corrección 1: Declaración correcta de variable con tipo | |
string mensaje = "Hola Mundo"; | |
// Corrección 2: Punto y coma agregado al final de la declaración |
This file contains hidden or 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
using System; | |
class Program | |
{ | |
static void Main() | |
{ | |
mensaje = "Hola Mundo"; | |
int numero = 10 | |
This file contains hidden or 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
# Manipulación de un diccionario en Python | |
diccionario = {'nombre': 'Juan', 'edad': 30, 'ciudad': 'Ejemploville'} | |
# Agregar un nuevo elemento al diccionario | |
diccionario['ocupacion'] = 'Programador' | |
# Imprimir el diccionario | |
print(diccionario) |
This file contains hidden or 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
using System; | |
class Program | |
{ | |
static void Main() | |
{ | |
myVariable = 5; | |
WriteLine("Hola, mundo!"); |
This file contains hidden or 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
try | |
{ | |
using (FileStream fs = new FileStream("ruta/del/archivo.txt", FileMode.Open)) | |
{ | |
// Realizar operaciones con el archivo | |
} | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine("Error al abrir el archivo: " + ex.Message); |
This file contains hidden or 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
FileStream fs = null; | |
try | |
{ | |
fs = new FileStream("ruta/del/archivo.txt", FileMode. Open); | |
// Realizar operaciones con el archivo | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine("Error al abrir el archivo: " + ex.Message); | |
} |
This file contains hidden or 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
function factorial(n) | |
{ | |
if (n === 0 || n === 1) | |
{ | |
return 1; | |
} | |
else | |
{ | |
return n * factorial(n - 1); | |
} |
This file contains hidden or 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
function factorial(n) | |
{ | |
if (n === 0 || n === 1) | |
{ | |
return 1; | |
} | |
else | |
{ | |
let result = 1; | |
for (let i = 2; i <= n; i++) |