add lisp code for problem 31