You should be able to factor this out of the loop into some division and then just iterate on `xrange(1, ...)`