Finished Problem LCSM using recursion