An algorithm for the numerical solution of optimal control problems is developed which is based on a combination of the direct and indirect approaches. The method presented is similar to the indirect approach in that the known and iteratively improved unknown initial values are used in the integration of the system and Euler-Lagrange differential equations. However, instead of matching end conditions, as is done in the classical approach, the performance function is considered to be a function of the unknown initial values and optimized by a gradient technique, as is done in the direct approach. Since only terminal values are stored, the method can be useful in digital or hybrid controllers of limited memory. It is shown that it is sufficient to search for the intersection of a sphere with a line in the initial condition space. As a consequence, the method is not dependent on a good initial estimate of the initial values.