changed range to xrange
changed program to use smaller values in the hopes that they will improve performance