return processwhenever is an odd numberdo an additional multiplication by here' the sequence for = = = = = = = = = = returning = = returning = = returning = = returning = = / is oddso multiply by returning = = the knapsack problem the knapsack problem is classic in computer science in its simplest form it involves trying to fit items of different weights into knapsack so that the knapsack ends up with specified total weight you don' need to fit in all the items for examplesuppose you want your knapsack to weigh exactly poundsand you have five itemswith weights of and pounds for small numbers of itemshumans are pretty good at solving this problem by inspection so you can probably figure out that only the and combination of items adds up to if we want computer to solve this problemwe'll need to give it more detailed instructions here' the algorithm if at any point in this process the sum of the items you selected adds up to the targetyou're done start by selecting the first item the remaining items must add up to the knapsack' target weight minus the first itemthis is new target weight tryone by oneeach of the possible combinations of the remaining items noticehoweverthat you don' really need to try all the combinationsbecause whenever the sum of the items is more than the target weightyou can stop adding items if none of the combinations workdiscard the first itemand start the whole process again with the second item continue this with the third item and so on until you've tried all the combinationsat which point you know there is no solution