added initial implementation of 2nd question of recursion & dynamic programming