version in common lisp
problem 1 in python