Prime Finding Algorithm 썸네일형 리스트형 Dijkstra's Hidden Prime Finding Algorithm https://www.youtube.com/watch?app=desktop&v=fwxjMKBMR7s 몰랐던걸 알았다... import heapq import time # dijkstraPrimes_heapq_2 함수 정의 def dijkstraPrimes_heapq_2(n): pool = [(4, 2)] primes = [2] for i in range(3, n): current_value, current_prime = heapq.heappop(pool) if current_value > i: heapq.heappush(pool, (i**2, i)) primes.append(i) else: while current_value 더보기 이전 1 다음