recursive solution to the stock pipe cut problem