This paper describes a simple mathematical technique that uses a genetic algorithm and least squares optimization to obtain a functional approximation (or computer program) for a given data set. Such an optimal functional form is derived from a pre-defined general functional formulation by selecting optimal coefficients, decision variable functions, and mathematical operators. In the past, functional approximations have routinely been obtained through the use of linear and non-linear regression analysis. More recent methods include the use of genetic algorithms and genetic programming. An example application based on a data set extracted from the commonly used Moody diagram has been used to demonstrate the utility of the proposed method. The purpose of the application was to determine an explicit expression for friction factor and to compare its performance to other available techniques. The example application results in the development of closed form expressions that can be used for evaluating the friction factor for turbulent pipe flow. These expressions compete well in accuracy with other known methods, validating the promise of the proposed method in identifying useful functions for physical processes in a very effective manner. The proposed method is simple to implement and has the ability to generate simple and compact explicit expressions for a given response function.