Today we shall have a look at a neat little trick that is more commonly seen in computational contests, but occasionally makes an appearance in Olympiad problems as well.
Let be an integer in base-
where
for all
, as usual. Observe that if
is the integer obtained by moving the first digit to the end,
Hence, it is clear that . More generally,
. Thus an
digit base-
number modulo
is naturally a circular string of digits. Multiplying by
rotates the circle by one position, and a carry beyond the
th position wraps back to the first position.

Let us begin with the following classical problem.
Example 1 (IMO Shortlist 1993 N3)
Let be positive integers,
and
Show that the representation of the number
in the base
contains at least
digits different from zero.
Suppose where
where
is the number of non-zero digits of
. We wish to show that
is at least
, given that
is a multiple of
. Our goal then turns to showing that the sum of digits of
is at least
, since each digit is at most
.
Naturally, since , the first thing to try is reducing every exponent
. Replacing
, we can define
which since
implies
.
But, this alone is useless. Note that a digit sitting in the position contributes far more to the sum
than a digit at the units position. We are trying to bound the number of non-zero digits — which should not depend on their positions, but our inequalities are highly position dependent.
To see what I mean, consider the example and
. We want to understand multiples of
, so reducing the powers of
modulo
gives
for positive integers . Thus,
is a multiple of
whenever
is. However,
is weighted 100 times as much as
, and
is weighted 10 times as much, so this does not tell us much about
, the actual digit sum.
However, multiplication by shows that
is a multiple of
, and similarly that
is a multiple of
. Hence, each of these are at least
so summing and dividing across by 111 immediately spits out the inequality
, which matches our target.
The key idea is that the contribution by a non-zero digit is not felt only from its current position but throughout all of the possible positions in the digit number. This intuition appears time and time again in these kinds of problems.
Returning to our problem, for , define the sums
.
In other words, throw the digits onto a circle, and then rotate it exactly steps. Note that as we perform the rotations, any digit
visits each of the
positions exactly once. So its total contribution to
is exactly
.
Summing across all the non-zero digits we have,
which since are all multiples of
implies
so
!
Now, this next problem might seem a bit unreasonable — especially for those who haven’t seen this trick before. So, it is best to first attempt 2025 CMIMC A5, which is basically the same problem but far less scary.
Example 2 (IMO Shortlist 2022 N5)
For each and
, define
to be the total number of times the digit
appears when all the multiples of
between
and
inclusive are written out in base
.
Show that there are infinitely many
such that there are precisely two distinct values among
,
,
,
.
The idea is to pick where
since
for this choice of
, and write every integer multiple of 1829 upto
as a
digit string, allowing leading zeros. Hence, for any multiple
of 1829, it’s cyclic rotation
is equivalent modulo
and is hence also divisible by 1829.
Now, since 1829 is a bit of a mouthful, let us pick the smaller choice 37 instead. Why 37? Because it so happens that 37 is a factor of 999, so remains within our sights. The list of multiples of 37 up to 999 goes as follows,
037, 074, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 703, 740, 777, 814, 851, 888, 925, 962, 999
We now group the multiples which are cyclic shifts of each other, while allowing for leading zeros,
037
370
703
074
740
407
148
481
841
185
851
518
259
592
925
296
962
629
and of course, 111, 222, 333, 444, 555, 666, 777, 888 and 999.
Notice that the distribution of digits in the hundreds, tens and units places are exactly identical! Hence, we only need focus on the units position.
Returning to the problem, the multiples of 1829 from 1 to our choice of have the same distribution of digits in each of the positions from
through the units position. Hence, we only need to count the number of times each non-zero digit occurs in the units position. However, since 1829 and 10 are relatively prime, the units digit of multiples of 1829 are periodic modulo 10.
Observe that the number of multiples of 1829 from 1 to is
, so each of the digits 0 through 8 occur
times while 9 occurs
times, implying that
, as desired.
For the finale, we shall have a look at a problem of a more constructive flavour. The solution to this problem can seem almost magical without the underlying motivation of cyclic shifts.
Example 3 (USAMO 2013/5)
Given positive integers and
, prove that there is a positive integer
such that the numbers
and
have the same number of occurrences of each non-zero digit when written in base ten.
Well, by now you know the drill — we would love to be able to find some integer such that the two multiples
and
are cyclic shifts of each other. Note that it suffices to deal with the case where
is relatively prime to 10 and
(confirm why!).
Consider and
such that
. If we can find
such that
has leftmost digit 1 at the
position, we would be done. Rearranging,
. However observe,
which implies that the leading digit is indeed at the position and is 1. We now need to pick
such that this choice of
is an integer, which is straightforward.