Created
April 27, 2020 15:14
-
-
Save dongho-jung/5583edba69599ec0853af75d47c116f5 to your computer and use it in GitHub Desktop.
get prime numbers. credit to https://codereview.stackexchange.com/a/121869
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
def get_primes(n): | |
for i in itertools.chain([2], itertools.count(3, 2)): | |
if n <= 1: return | |
while n%i == 0: | |
n /= i | |
yield i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment