Apply divisibility rules (#823)