Great Carl! I was aware of the problem with memory, because when the computer makes it's way through the recursive procedure it need to hold all information on it's way! So I assume you need to choose the iterative method if the number of boxes is too large. Maybe you need to know a bit more about my "do something here". Here I mean that when the computer has arrived at a certain state corresponding to a box combination, say [10,5,8,9,0,8] - meaning 10 marbles in box 1, 5 marbles in box 2, etc - then the information about this combination should be available, so that a third quantity: som function of the box combination can be calculated. In the end I wish as output a list of the results of having applied the real-valued function to every box combination:
List = [f([40,0,0,0,0,0]), f([39,1,0,0,0,0]), ... , f([0,0,0,0,0,40])]
I will look closer at your code. Thanks a lot!