import math V = [1, 3, 4] N = len(V) S = 6 def leiaKogus(S): if S < 0: return math.inf elif S == 0: return 0 else: vastus = math.inf for i in V: vastus = min(vastus, 1 + leiaKogus(S - i)) return vastus print(leiaKogus(S))