print('Hello world!')
import matplotlib.pyplot as plt
def es_primo(numero):
if numero <= 1:
return False
if numero == 2:
return True
if numero % 2 == 0:
return False
for i in range(3, int(numero**0.5) + 1, 2):
if numero % i == 0:
return False
return True
def primeros_n_primos(n):
numeros_primos = []
numero = 2
while len(numeros_primos) < n:
if es_primo(numero):
numeros_primos.append(numero)
numero += 1
return numeros_primos
# Obtener los primeros 1000 números primos
primeros_mil_primos = primeros_n_primos(1000)
# Graficar los primeros 1000 números primos
plt.figure(figsize=(12, 6))
plt.plot(primeros_mil_primos, marker='o', markersize=3, linestyle='None', color='b')
plt.title('Primeros 1000 Números Primos')
plt.xlabel('Índice')
plt.ylabel('Número Primo')
plt.grid(True)
plt.show()
To embed this project on your website, copy the following code and paste it into your website's HTML: