Implement factorial and square list | Morgan Stanley Interview Question