Have a look at the modulus operator (//). It should simplify what you're trying to do.