Skip to content

Instantly share code, notes, and snippets.

@tejuafonja
Created August 1, 2018 11:06
Show Gist options
  • Save tejuafonja/2701f9c2e0bac9541d14f7e3c6db0cad to your computer and use it in GitHub Desktop.
Save tejuafonja/2701f9c2e0bac9541d14f7e3c6db0cad to your computer and use it in GitHub Desktop.
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