added solutions 4 and 5
This commit is contained in:
parent
e51a602c87
commit
1231e9562e
12
problem3.py
12
problem3.py
@ -1,12 +1,18 @@
|
|||||||
prime = 13195
|
prime = 600851475143
|
||||||
current_num = prime
|
current_num = prime
|
||||||
factors = []
|
factors = []
|
||||||
|
ran = False
|
||||||
|
hit = False
|
||||||
|
|
||||||
while current_num != 1:
|
while current_num != 1 and not ran:
|
||||||
for i in range(2,current_num + 1):
|
for i in range(2,current_num + 1):
|
||||||
if current_num % i == 0:
|
if current_num % i == 0:
|
||||||
print('got a hit: ' + str(current_num) + str(factors))
|
print('got a hit: ' + str(current_num) + str(factors))
|
||||||
factors.append(i)
|
factors.append(i)
|
||||||
current_num /= i
|
current_num //= i
|
||||||
|
hit = True
|
||||||
|
if not hit:
|
||||||
|
ran = False
|
||||||
|
|
||||||
print(factors)
|
print(factors)
|
||||||
|
print('the largest prime factor is: ' + str(max(factors)))
|
||||||
|
9
problem4.py
Normal file
9
problem4.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
highest_value = 0
|
||||||
|
|
||||||
|
for i in range(100,1000):
|
||||||
|
for j in range(100,1000):
|
||||||
|
if str(i*j) == str(i*j)[::-1]:
|
||||||
|
if i*j > highest_value:
|
||||||
|
highest_value = i*j
|
||||||
|
|
||||||
|
print(highest_value)
|
16
problem5.py
Normal file
16
problem5.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
done = False
|
||||||
|
key = 1
|
||||||
|
|
||||||
|
def modulo(n):
|
||||||
|
for i in range(1,21):
|
||||||
|
if n % i != 0:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
while not done:
|
||||||
|
num = key*20
|
||||||
|
done = modulo(num)
|
||||||
|
|
||||||
|
key += 1
|
||||||
|
|
||||||
|
print(num)
|
Loading…
Reference in New Issue
Block a user