<jupyter_start><jupyter_text><jupyter_code>def criba(n):
  if n >= 2:
    numbers = list(range(n+1))
    primes = []
    for i in range(2, n+1):
      if numbers[i] > 0:
        primes.append(i)
        for j in range(i * 2, n+1, i):
          numbers[j] = -i
  return primes

%timeit criba(100)
%timeit criba(500)
%timeit criba(1000)<jupyter_output>10000 loops, best of 5: 25.8 µs per loop
10000 loops, best of 5: 145 µs per loop
1000 loops, best of 5: 310 µs per loop<jupyter_text>Criba de Eratostenes menos eficientes<jupyter_code>def criba_eratostenes(n):  
  primos=[]
  no_primos=[]
 
  for i in range(2, n+1):
    if i not in no_primos:
      primos.append(i)

      for j in range(i*i, n+1, i):
        no_primos.append(j)

  return primos

%timeit criba_eratostenes(100)
%timeit criba_eratostenes(500)
%timeit criba_eratostenes(1000)
def mark(n):
    if n < 2:
        return
    numbers = list(range(2,n + 1))
    numbers2 = list(range(2,n + 1))
    for i in range(n - 1):
        for j in range(i + 1, n - 2):
            if numbers[j] % numbers[i] == 0:
                numbers2[j] = -1
    primes = list()
    for k in range(n - 2):
        if numbers2[k] != -1:
            primes.append(numbers[k])
    return primes

%timeit mark(100)
%timeit mark(500)
%timeit mark(1000)<jupyter_output>1000 loops, best of 5: 569 µs per loop
100 loops, best of 5: 14.8 ms per loop
10 loops, best of 5: 60.5 ms per loop
{'fraction_non_alphanumeric': 0.12764456981664316, 'fraction_numerical': 0.07193229901269393, 'mean_word_length': 2.7049608355091386, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '237992', 'license': 'CC0-1.0', 'n_tokens_mistral': 660, 'n_tokens_neox': 574, 'n_words': 168, 'path': '4_CribaDeErastotenes.ipynb', 'repo_name': 'RodriCalle/ComplejidadAlgoritmica', 'size': '1418'}