Source: https://www.people.vcu.edu/~rhammack/Discrete/SolutionsFunctions.pdf