  Considering a real-valued diffusion, a real-valued reward function and a
positive discount rate, we provide an algorithm to solve the optimal stopping
problem consisting in finding the optimal expected discounted reward and the
optimal stopping time at which it is attained. Our approach is based on
Dynkin's characterization of the value function. The combination of Riesz's
representation of $\alpha$-excessive functions and the inversion formula gives
the density of the representing measure, being only necessary to determine its
support. This last task is accomplished through an algorithm. The proposed
method always arrives to the solution, thus no verification is needed, giving,
in particular, the shape of the stopping region. Generalizations to diffusions
with atoms in the speed measure and to non smooth payoffs are analyzed.
