half the prime number

2 secs 1024 MB
AiletS's icon AiletS

アリストテレスの篩を用いて素数を全列挙すると解を求めることができます。計算量はO(NloglogN)\mathcal{O}(NloglogN)で十分高速です。