N = 3 V = [1, 3, 4] A={0:0} def leiaKogus(S): if (S < 0): A[S]=100000 if S not in A: vastus = 1000000 for i in range (N): vastus = min(vastus, 1 + leiaKogus(S - V[i])) A[S]=vastus return A[S] print(leiaKogus(6))