Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import combinations
- def dels(x):
- d = set()
- for i in range(1, int(x ** 0.5) + 1):
- if x % i == 0:
- d.add(i)
- d.add(x // i)
- d = list(d)
- d.remove(x)
- return sorted(d)
- def check(n):
- d = dels(n)
- if len(d) < 2: return False
- for i in range(2, len(d) + 1):
- x = [[int(z) for z in q] for q in combinations(d, r=i)]
- if any([1 if sum(q) == n else 0 for q in x]):
- return True
- return False
- for i in range(300, 350 + 1):
- if check(i):
- print(i, end=' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement