Skip to content

Instantly share code, notes, and snippets.

@kamilsj
Created January 9, 2016 14:23
Show Gist options
  • Save kamilsj/c426c1e44871509e352d to your computer and use it in GitHub Desktop.
Save kamilsj/c426c1e44871509e352d to your computer and use it in GitHub Desktop.
Algorithm to Euler Projects
def euler1(arg):
i = 0
sum = 0
while i<1000:
if i%3 == 0 or i%5 == 0:
sum = sum + i
i = i+1
print sum
def euler3(arg):
i = 2
n = 600851475143
primes = []
while n != 1:
if n % i == 0:
primes.append(i)
n /= i
i = 2
else:
i += 1
print primes
def euler2(arg):
sum = 0
x = 1
y = 2
while x < 4000000:
if x % 2 == 0:
sum += x
x, y = y, x+y
print sum
def euler4(arg):
x = 100
y = 100
highest = 0
while x < 1000:
x += 1
while y < 1000:
sum = x*y
if str(sum) == str(sum)[::-1]:
if sum > highest:
highest = sum
y += 1
y = 100
print highest
if __name__ == '__main__':
euler5(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment