Answer the question
In order to leave comments, you need to log in
An algorithm that would search in an array of numbers for those from the sum of which you can get a given number?
How can it be implemented?
For example, number: 12
Array of numbers: 6 2 4 9 11 3
Output: 6 2 4
If there are several combinations, outputs any
Answer the question
In order to leave comments, you need to log in
num = int(input())
numList = []
while True:
num2 = input()
if num2 != '':
numList.append(int(num2))
else:
break
numList2 = []
for elem in numList:
if num%elem == 0:
numList2.append(elem)
for elem in numList2:
print(elem)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question