Source: https://www.bowdoin.edu/~ltoma/teaching/cs231/fall04/Lectures/reccurences.pdf