Skip to content

Instantly share code, notes, and snippets.

@ftvs
Created November 16, 2014 13:08
Show Gist options
  • Save ftvs/b2e6618beaf284e160a5 to your computer and use it in GitHub Desktop.
Save ftvs/b2e6618beaf284e160a5 to your computer and use it in GitHub Desktop.
Project Euler
import os, sys
if __name__ == '__main__':
print("Python Version: " + sys.version)
print("Python Executable: " + sys.executable)
print("Env var TEST_NAME: " + os.getenv('TEST_NAME', None))
def primes(maxprime):
primes = [2]
print("primes: " + str(primes))
for i in range(2, maxprime):
isprime = True
for prime in primes:
# print("prime: " + str(prime))
# if prime == 0:
# break
if (i % prime) == 0:
isprime = False
continue
if isprime:
primes.append(i)
return primes
def is_evenly_divisible(n, min_divisor, max_divisor, allprimes):
# for i in range(min_divisor, max_divisor):
# remainder = (n % i)
# print(str(remainder))
# if remainder != 0:
# return False
#
# return True
i = allprimes[0]
for prime in allprimes:
if prime < min_divisor:
continue
elif prime > max_divisor:
break
if (n % prime) != 0:
return False
return True
def smallest_evenly_divisible(maxnum, min_divisor, max_divisor):
allprimes = primes(max_divisor)
print(str(primes(100)))
print(str(is_evenly_divisible(2520, 1, 10)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment