Help us understand the problem. What is going on with this article?

Project Euler 50「連続する素数の和」

More than 1 year has passed since last update.

@cof さんに頂いたコメント内の関数（get_prime_boolean）を丸パクリ。
いやはや、よくできてますねこの関数。美しいです。
ちゃんと内容理解したからコピペしちゃっていいですよね。

Problem 50 「連続する素数の和」

41 = 2 + 3 + 5 + 7 + 11 + 13.
100未満の素数を連続する素数の和で表したときにこれが最長になる.

100万未満の素数を連続する素数の和で表したときに最長になるのはどの素数か?

```def hoge(num):
primes = [ i for i, b in enumerate(get_prime_boolean(num)) if b ]
cnt, ans = 1, 0
for n in range(len(primes)):
if primes[n] > num / cnt: break
for m in range(n + cnt, len(primes) + 1):
N = sum(primes[n:m])
if N >= num: break
if m - n > cnt and N in primes:
cnt, ans = m - n, N
return ans

def get_prime_boolean(search_max):
prime_boolean = [False,False] + [True] * (search_max-1)
prime_boolean[4::2] = [False] * (len(prime_boolean[4::2]))
p = 3
p_max = int(search_max ** 0.5) + 1
while p <= p_max:
if prime_boolean[p]:
prime_boolean[p**2::p] = [False] * (len(prime_boolean[p**2::p]))
p += 2
return prime_boolean

print(hoge(1000000))
```

Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away