upload solutions for 1, 2 and 3
This commit is contained in:
parent
4ca5386cd9
commit
b1d8ca66a7
7
1.py
Normal file
7
1.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
sum = 0
|
||||||
|
|
||||||
|
for i in range(1000):
|
||||||
|
if (i % 3 == 0 or i % 5 == 0):
|
||||||
|
sum += i
|
||||||
|
|
||||||
|
print(sum)
|
17
2.py
Normal file
17
2.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
sum = 0
|
||||||
|
memo = [1,2]
|
||||||
|
while True:
|
||||||
|
i = len(memo)
|
||||||
|
a = memo[i-1]
|
||||||
|
b = memo[i-2]
|
||||||
|
if a+b > 4000000:
|
||||||
|
break
|
||||||
|
memo.append(a+b)
|
||||||
|
|
||||||
|
|
||||||
|
for i in memo:
|
||||||
|
if (i % 2 == 0):
|
||||||
|
sum += i
|
||||||
|
|
||||||
|
|
||||||
|
print(sum)
|
22
3.py
Normal file
22
3.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import math
|
||||||
|
|
||||||
|
def maxPrimeFactors (n):
|
||||||
|
maxPrime = -1
|
||||||
|
|
||||||
|
while n % 2 == 0:
|
||||||
|
maxPrime = 2
|
||||||
|
n /= 2
|
||||||
|
|
||||||
|
for i in range(3, int(math.sqrt(n)) + 1, 2):
|
||||||
|
while n % i == 0:
|
||||||
|
maxPrime = i
|
||||||
|
n = n / i
|
||||||
|
if n > 2:
|
||||||
|
maxPrime = n
|
||||||
|
|
||||||
|
return int(maxPrime)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
n = 600851475143
|
||||||
|
print(maxPrimeFactors(n))
|
Loading…
Reference in New Issue
Block a user