1
1

upload solutions for 1, 2 and 3

This commit is contained in:
Rokas Puzonas 2023-05-11 22:38:12 +03:00
parent 4ca5386cd9
commit b1d8ca66a7
3 changed files with 46 additions and 0 deletions

7
1.py Normal file
View 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
View 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
View 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))