-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path23.py
51 lines (35 loc) · 865 Bytes
/
23.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 15:47:32 2020
@author: santi
"""
def lista_divisores(n):
"""
Recibe un numero n y devuelve una lista de sus divisores
"""
lista = []
for i in range(1,n):
if n % i == 0:
lista.append(i)
return lista
def suma_divisores(n):
"""
Recibe un numero n y devuelve la suma de sus divisores
"""
suma = 0
for i in lista_divisores(n):
suma += i
return suma
def es_abundante(a):
return a < suma_divisores(a)
lista = []
lista2 = []
for i in range(12,28123):
if es_abundante(i):
lista.append(i)
for i in lista:
for p in lista[lista.index(i):]:
if (i+p) <= 28123:
lista2.append(i+p)
lista2 = list(dict.fromkeys(lista2))
suma = ((28123*28124)/2) - sum(lista2)