exupero's blog

# Best base for modulo tricks?

In the previous post I showed how common modulo tricks for 2, 3, 5, 9, 10, and 11 are the product of our chosen base-10 number system, and that the kinds of divisibility graphs that indicate these techniques appear in any base system for the numbers that are equal to the numerical base, one less than the base, and one more than the base, as well as for any factors of those numbers. Realizing, then, that base-10 only produces 6 numbers that can exploit this due to the few factors of 9, 10, and 11, it's natural to ask whether there are any base systems which produce more modulo tricks.

Here's a table listing the relevant factor counts up to base 10:

BaseFactors of baseFactors of base - 1Factors of base + 1Total
21012
31124
42114
51236
63115
71337
83126
92338
103216

While it looks like base 9 gives us two more modulo tricks than base 10, it really only gives us one since 2 is counted twice, once as a factor of 8 and again as a factor of 10. Here's a tally of the unique factors:

BaseFactors of baseFactors of base - 1Factors of base + 1Unique
21012
31123
42114
51235
63115
71336
83126
92337
103216

Base 9 gives us tricks for 4 and 8, but we lose the trick for 11.

What about bases higher than 10? Here are the top five contenders, up to base 20:

BaseFactors of baseFactors of base - 1Factors of base + 1Unique
1915510
153349
171459
205139
111358

Notice that while the number of unique factors with tricks has increased to 10 with base 19, the total fraction of numbers with tricks has decreased, down to almost 50% of the base. Measuring percent coverage weighs small bases more heavily:

BaseFactors of baseFactors of base - 1Factors of base + 1UniquePercentage
21012100%
31123100%
42114100%
51235100%
7133685%

We can also score bases by how easily different modulo techniques can be performed. The easiest tricks are those for the factors of the base itself, for which we only need to check the last digit. The next easiest are those for factors of one less than the base, for which we add up the digits. The least easy are those for factors of one more than the base, for which we have to alternate between adding and subtracting digits. Here are the weighted rankings:

BaseFactors of base (weight 3)Factors of base - 1 (weight 2)Factors of base + 1 (weight 1)Score
2051320
1643119
1251118
1533418
1851118
1915517
1315315
1714515
923314
1032114
1431314
831213
1113513
631112
713311
42119
51239
31126
21014

While weighing like this bumps up some of the most common alternate base systems (20, 16, and 12), it also clearly favors large bases with many factors. We get even better scores from impractically large bases:

BaseFactors of base (weight 3)Factors of base - 1 (weight 2)Factors of base + 1 (weight 1)Score
120153253
144143351
96113140
126113140
84111338

The question of best base for modulo tricks, then, involves more than just maximizing the number of modulo tricks. A ratio like percent coverage might be the right approach after all, as it penalizes larger bases. Eliminating bases smaller than 8, the next best coverage comes from base 9:

BaseFactors of baseFactors of base - 1Factors of base + 1UniquePercentage
9233777%
8312675%
11135872%
13153861%
10321660%
15334960%
12511758%
17145952%
191551052%
14313750%

It seems there is no objectively "best" base for generating modulo tricks.

If you have suggestions for further analysis, please email me.