def comp_chips(n): L = [0,1,2,3,4,1,2,3,1] if n > 8: i = 9 while i <= n: L.append(min(L[i-1],L[i-5],L[i-8])+1) i += 1 print(L) return L[n]
comp_chips(15)
This would mean that you need at least 3 packages for 15 computer chips.