Created
August 1, 2018 11:06
-
-
Save tejuafonja/2701f9c2e0bac9541d14f7e3c6db0cad to your computer and use it in GitHub Desktop.
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
def is_prime(number): | |
if number > 1: | |
if number == 2: | |
return True | |
if number % 2 == 0" | |
return False | |
for current in range(3, int(math.sqrt(number) +1), 2): | |
if number % current == 0: | |
return False | |
return True | |
return False | |
def get_primes(number): | |
while True: | |
if is_prime(number): | |
yield number | |
number += 1 | |
def get_prime_up_to(from_, to): | |
total = 2 | |
for next_prime in get_primes(from_): | |
if next_prime < to: | |
total += next_prime | |
else: | |
print (total) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment