Russian peasant algorithm.