An optimized algorithm for allowing the autonomous search of a radioactive source has been designed and implemented as a firmware on an UAV. The algorithm has been designed to comply with several constraints imposed by UAV and by the radiation sensor, in terms of electrical autonomy and time duration of the measurement process. The algorithm implements a gradient descent strategy which allows to recover, with a good spatial resolution, the radiation source whose position and type (i.e., activity) is not a priori known. The algorithm was validated through a Monte Carlo simulation and incorporates problem's constraints regarding the search area. Simulation results show that the UAV is able to appropriately locate the source location with high success rate during a single UAV mission and to estimate the total time of the operation.