LCM function for python.