Esiste anche l'operatore modulo (%) che fa esattamente quello che dici tu.