昨日書いたコードはぶっちゃけ、速くないdeath。 まぁ、教科書的?というか遅いとわかっているメソッドつかってますからね。 速くするならこんな感じ? def eratosthenes(n): n = int(n) if n < 2: return [] sqrtn = 1 + int(n**0.5) primes = [2, 3] cands = [x for x in range(5, n+1, 2) if x%3] while (cands[0] <= sqrtn): prime = cands.pop(0) primes.append(prime) cands = [x for x in…