manolis tsamis wrote:I am currently using that but because it's repeated million times modulus is slowing it down... I was searching for another thing to do
Are you absolutely sure that it's the modulus that's slowing you down? Most attempts at efficiency end up focusing on the wrong thing, so you'd better be able to prove that its the '%' that's causing all your problems before you start looking for a "better %".
That said, there are faster ways of doing it, the most basic being if d (your divisor) is a power of two:
x % d == x & (d-1)
but you'd better be awfully sure it's going to help before you start littering your program with arcane crap like that.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here