Abacus tricks for faster calculation