Library · Between the Challenge and the Olympiad · Chapter 3

Digits, Bases and Representation

Revised Report an error
On this page
  1. Problems
  2. Solutions
  3. Solution: IOQM 2024, Q3
  4. Solution: IOQM 2026, Q4
  5. Solution: PRMO 2014, Q2
  6. Solution: PRMO 2015 Part A, Q6
  7. Solution: PRMO 2015 Part A, Q7
  8. Solution: PRMO 2018, Q3
  9. Solution: PRMO 2018, Q4
  10. Solution: PRMO 2019, Q6
  11. Solution: IOQM 2020, Q2
  12. Solution: IOQM 2024, Q8
  13. Solution: IOQM 2025 Part SEP, Q7
  14. Solution: IOQM 2026, Q9
  15. Solution: IOQM 2026, Q14
  16. Solution: PRMO 2013, Q6
  17. Solution: PRMO 2013, Q20
  18. Solution: PRMO 2015 Part A, Q20
  19. Solution: PRMO 2017, Q1
  20. Solution: PRMO 2018, Q20
  21. Solution: IOQM 2020, Q8
  22. Solution: IOQM 2021 Part A, Q4
  23. Solution: IOQM 2024, Q21
  24. Solution: IOQM 2025 Part SEP, Q28
  25. Solution: IOQM 2026, Q20
  26. Solution: PRMO 2018, Q19
  27. Solution: PRMO 2018, Q30
  28. Solution: IOQM 2023, Q19
  29. Solution: IOQM 2023, Q26

Problems

Problem 1

The number obtained by taking the last two digits of 520245^{2024} in the same order is:

Problem 2

All six digits of three 22-digit numbers are different. If NN is the largest possible sum of three such numbers, what is the sum of digits of NN?

Problem 3

The first term of a sequence is 20142014. Each succeeding term is the sum of the cubes of the digits of the previous term. What is the 2014th2014^{\text{th}} term of the sequence?

Problem 4

Let E(n)E(n) denote the sum of the even digits of nn. For example, E(1243)=2+4=6E(1243) = 2 + 4 = 6. What is the value of E(1)+E(2)+E(3)+⋯+E(100)E(1) + E(2) + E(3) + \cdots + E(100)?

Problem 5

How many two-digit positive integers NN have the property that the sum of NN and the number obtained by reversing the order of the digits of NN is a perfect square?

Problem 6

Consider all 6-digit numbers of the form abccbaabccba where bb is odd. Determine the number of all such 6-digit numbers that are divisible by 77.

Problem 7

The equation 166×56=8590166 \times 56 = 8590 is valid in some base b≥10b \geq 10 (that is, 1,6,5,8,9,01, 6, 5, 8, 9, 0 are digits in base bb in the above equation). Find the sum of all possible values of b≥10b \geq 10 satisfying the equation.

Problem 8

Let abc‾\overline{abc} be a three digit number with nonzero digits such that a2+b2=c2a^2 + b^2 = c^2. What is the largest possible prime factor of abc‾\overline{abc}?

Problem 9

A number NN in base 10, is 503503 in base bb and 305305 in base b+2b + 2. What is the product of the digits of NN?

Problem 10

Let nn be the smallest integer such that the sum of digits of nn is divisible by 55 as well as the sum of digits of (n+1)(n+1) is divisible by 55. What are the first two digits of nn in the same order?

Problem 11

How many 3-digit numbers abc‾\overline{abc} in base 10 are there with a≠0a \neq 0 and c=a+bc = a + b?

Problem 12

Let NN be the smallest positive integer whose digits add up to 20262026. What is the leading digit of N+1N + 1?

Problem 13

Let AA be a 33-digit number with distinct nonzero digits and BB be the number obtained by reversing the digits of AA. Determine the largest possible prime factor of ∣A−B∣|A - B|.

Problem 14

Let S(M)S(M) denote the sum of the digits of a positive integer MM written in base 10. Let NN be the smallest positive integer such that S(N)=2013S(N) = 2013. What is the value of S(5N+2013)S(5N + 2013)?

Problem 15

What is the sum (in base 10) of all the natural numbers less than 64 which have exactly three ones in their base 2 representation?

Problem 16

The digits of a positive integer nn are four consecutive integers in decreasing order when read from left to right. What is the sum of the possible remainders when nn is divided by 37?

Problem 17

How many positive integers less than 1000 have the property that the sum of the digits of each such number is divisible by 7 and the number itself is divisible by 3?

Problem 18

Determine the sum of all possible positive integers nn, the product of whose digits equals n2−15n−27n^2 - 15n - 27.

Problem 19

A 5-digit number (in base 10) has digits kk, k+1k+1, k+2k+2, 3k3k, k+3k+3 in that order, from left to right. If this number is m2m^2 for some natural number mm, find the sum of the digits of mm.

Problem 20

Consider the set of all 6-digit numbers consisting of only 3 digits, a,b,ca, b, c, where a,b,ca, b, c are distinct. Suppose the sum of all these numbers is 593999406593999406. What is the largest remainder when the three digit number abcabc is divided by 100100?

Problem 21

An integer nn is such that ⌊n9⌋\left\lfloor \dfrac{n}{9} \right\rfloor is a three digit number with equal digits, and ⌊n−1724⌋\left\lfloor \dfrac{n-172}{4} \right\rfloor is a 44 digit number with the digits 2,0,2,42, 0, 2, 4 in some order. What is the remainder when nn is divided by 100100?

Problem 22

Let NN be the coefficient of x2025x^{2025} in the expansion of (x+1)(x2+3)(x4+5)(x8+7)⋯(x1024+21).(x+1)(x^2+3)(x^4+5)(x^8+7)\cdots(x^{1024}+21). What is the remainder when NN is divided by 100?

Problem 23

Let mm be a positive integer satisfying the equation 5(2m+1)(2m+3)(2m+5)=ababab‾5(2m+1)(2m+3)(2m+5) = \overline{ababab} where aa and bb represent different digits and ababab‾\overline{ababab} is a six digit number. What is the value of m+a+bm + a + b?

Problem 24

Consider five-digit positive integers of the form abcab‾\overline{abcab} that are divisible by the two digit number ab‾\overline{ab} but not divisible by 13. What is the largest possible sum of the digits of such a number?

Problem 25

Let MM be the smallest positive integer with the following two properties:

(a) The leading digit of MM is equal to 33.

(b) If NN is the number obtained by moving this leading 33 to the units place, and shifting all the other digits one place to the left, then N=M/4N = M/4.

What is the sum of the digits of MM?

Problem 26

Let N=6+66+666+⋯+666⋯66N = 6 + 66 + 666 + \cdots + 666\cdots 66, where there are hundred 6’s in the last term in the sum. How many times does the digit 77 occur in the number NN?

Problem 27

Let P(x)=a0+a1x+a2x2+⋯+anxnP(x) = a_0 + a_1x + a_2x^2 + \cdots + a_nx^n be a polynomial in which aia_i is a non-negative integer for each i∈{0,1,2,3,⋯ ,n}i \in \{0, 1, 2, 3, \cdots, n\}. If P(1)=4P(1) = 4 and P(5)=136P(5) = 136, what is the value of P(3)P(3)?

Problem 28

For n∈Nn \in \mathbb{N}, let P(n)P(n) denote the product of the digits in nn and S(n)S(n) denote the sum of the digits in nn. Consider the set A={n∈N:P(n) is non-zero, square free and A = \{n \in \mathbb{N} : P(n) \text{ is non-zero, square free and } S(n) is a proper divisor of P(n)}.S(n) \text{ is a proper divisor of } P(n)\}. Find the maximum possible number of digits of the numbers in AA.

Problem 29

In the land of Binary, the unit of currency is called Ben and currency notes are available in denominations 1,2,22,23,…1, 2, 2^2, 2^3, \ldots Bens. The rules of the Government of Binary stipulate that one can not use more than two notes of any one denomination in any transaction. For example, one can give a change for 2 Bens in two ways: 2 one Ben notes or 1 two Ben note. For 5 Ben one can give 1 one Ben note and 1 four Ben note or 1 one Ben note and 2 two Ben notes. Using 5 one Ben notes or 3 one Ben notes and 1 two Ben notes for a 5 Ben transaction is prohibited. Find the number of ways in which one can give change for 100 Bens, following the rules of the Government.

Problem 30

How many four digit numbers abcd‾\overline{abcd}, with non-zero digits a,b,c,da, b, c, d in base 10, are there such that a+c=bda + c = bd and b+d=acb + d = ac?

Solutions

Solution: IOQM 2024, Q3

Key idea

Once a power of 55 has two digits it ends in 2525, and multiplying by 55 again leaves those two digits unchanged.

Look at the pattern: 52=255^2 = 25, 53=1255^3 = 125, 54=6255^4 = 625, all ending in 2525. One line of algebra shows why. If a number ends in 2525, write it as 100m+25100m + 25; multiplying by 55 gives 500m+125=100(5m+1)+25500m + 125 = 100(5m+1) + 25, which again ends in 2525.

Since 525^2 ends in 2525, so does every higher power, and in particular 520245^{2024}. The last two digits are 2525.

Answer 25

Solution: IOQM 2026, Q4

Key idea

A tens digit counts ten times and a units digit once, so the three largest digits belong in the tens places.

If the numbers have tens digits a1,a2,a3a_1, a_2, a_3 and units digits b1,b2,b3b_1, b_2, b_3, their sum is 10(a1+a2+a3)+(b1+b2+b3).10(a_1 + a_2 + a_3) + (b_1 + b_2 + b_3). Suppose some units digit bb were larger than some tens digit aa. Swapping the two raises the sum by 10b+a−(10a+b)=9(b−a)>010b + a - (10a + b) = 9(b - a) > 0, so that choice was not the largest. In the best choice every tens digit beats every units digit: the tens digits are 9,8,79, 8, 7 and the units digits are 6,5,46, 5, 4.

That gives N=10⋅24+15=255,N = 10 \cdot 24 + 15 = 255, for instance as 96+85+7496 + 85 + 74, and the sum of the digits of NN is 2+5+5=122 + 5 + 5 = 12.

Answer 12

Solution: PRMO 2014, Q2

Key idea

Compute a few terms and look for a value whose digit-cube sum returns the same value; once that happens, the sequence stops changing.

Apply the rule twice: 2014↦23+03+13+43=73,73↦73+33=343+27=370.2014 \mapsto 2^3 + 0^3 + 1^3 + 4^3 = 73, \qquad 73 \mapsto 7^3 + 3^3 = 343 + 27 = 370. So the third term is 370370. Now apply it once more: 370↦33+73+03=27+343+0=370.370 \mapsto 3^3 + 7^3 + 0^3 = 27 + 343 + 0 = 370. The sequence has reached a fixed point and stays there. Since the 20142014th term is far beyond the third, x2014=370.x_{2014} = 370.

The three-digit numbers equal to the sum of the cubes of their digits are exactly 153153, 370370, 371371 and 407407, and 11 is a fixed point too. A sequence of this kind always falls into one of those or into a short cycle. It is worth knowing that the descent is quick: any four-digit number maps to at most 4×93=29164 \times 9^3 = 2916, so the sequence is trapped in a small range almost immediately.

Answer 370

Solution: PRMO 2015 Part A, Q6

Key idea

Counting by digit position rather than by number turns the whole sum into two identical tallies, because each digit slot runs over 00 through 99 equally often.

The number 100100 contributes nothing, since its only non-zero digit is odd, so the sum is really over 11 through 9999. It is convenient to pad these to two digits and include 0000 as well, writing every number from 0000 to 9999. The extra entry 0000 contributes nothing either, and now the list is completely regular: the units digit runs through 0,1,…,90,1,\ldots,9 exactly ten times, and so does the tens digit.

The even digits are 0,2,4,6,80, 2, 4, 6, 8, whose sum is 2020. Each digit position therefore contributes 10×20=20010 \times 20 = 200 to the total, and there are two positions, so E(1)+E(2)+⋯+E(100)=200+200=400.E(1) + E(2) + \cdots + E(100) = 200 + 200 = 400.

The move that made this easy was refusing to walk through the numbers one at a time. Whenever a question sums a digit-based function over a full block like 11 to 100100, padding to a fixed width and counting one column at a time is almost always the shorter road.

Answer 400

Solution: PRMO 2015 Part A, Q7

Key idea

A two-digit number and its reversal always add to 11(a+b)11(a+b), so being a perfect square forces 1111 to divide a+ba+b, and the digit sum has only one chance to manage it.

Write N=10a+bN = 10a + b with aa from 11 to 99 and bb from 00 to 99. The reversed number is 10b+a10b + a, and N+(10b+a)=11a+11b=11(a+b).N + (10b + a) = 11a + 11b = 11(a+b). For this to be a perfect square, the prime 1111 must appear to an even power, so 1111 must divide a+ba + b. Since a+ba + b is at most 9+9=189 + 9 = 18 and is positive, the only possibility is a+b=11a + b = 11, which indeed gives 11×11=121=11211 \times 11 = 121 = 11^2.

It remains to count the two-digit numbers whose digits sum to 1111. Choosing aa determines b=11−ab = 11 - a, and we need bb to be a digit, so 11−a≤911 - a \le 9, that is a≥2a \ge 2. Every aa from 22 to 99 works, giving 29,38,47,56,65,74,83,9229, 38, 47, 56, 65, 74, 83, 92, which is 88 numbers.

Answer 8

Solution: PRMO 2018, Q3

Key idea

Modulo 77 the palindrome collapses to 6a+c6a + c, because 1001010010 is a multiple of 77, so the condition is c≡ac \equiv a and the odd digit bb never matters.

Write the number out by place value: abccba‾=100001a+10010b+1100c.\overline{abccba} = 100001a + 10010b + 1100c. Reduce each coefficient modulo 77. Since 7×14285=999957 \times 14285 = 99995, we get 100001≡6100001 \equiv 6; since 7×1430=100107 \times 1430 = 10010 exactly, the middle coefficient vanishes; and since 7×157=10997 \times 157 = 1099, we get 1100≡11100 \equiv 1. So abccba‾≡6a+c(mod7).\overline{abccba} \equiv 6a + c \pmod 7.

Divisibility by 77 therefore means c≡−6a≡a(mod7)c \equiv -6a \equiv a \pmod 7, and bb is free to be any of the five odd digits.

Count the pairs (a,c)(a,c) with aa from 11 to 99, cc from 00 to 99 and c≡a(mod7)c \equiv a \pmod 7. For a given aa the admissible cc are those in {0,…,9}\{0,\ldots,9\} congruent to aa, and there are two of them when a≡0a \equiv 0, 11 or 2(mod7)2 \pmod 7 and one otherwise: a123456789#c221111222\begin{array}{c|ccccccccc} a & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ \hline \#c & 2 & 2 & 1 & 1 & 1 & 1 & 2 & 2 & 2 \end{array} That is 1414 pairs. Multiplying by the 55 choices of the odd digit bb, 14×5=70.14 \times 5 = 70.

Answer 70

Solution: PRMO 2018, Q4

Key idea

Reading both sides in base bb turns the statement into a cubic in bb, and b=12b = 12 is a root whose cofactor has no real zeros at all.

In base bb the two factors are 166b=b2+6b+6166_b = b^2 + 6b + 6 and 56b=5b+656_b = 5b + 6, and the product is 8590b=8b3+5b2+9b8590_b = 8b^3 + 5b^2 + 9b. Multiplying out the left-hand side, (b2+6b+6)(5b+6)=5b3+36b2+66b+36.(b^2 + 6b + 6)(5b + 6) = 5b^3 + 36b^2 + 66b + 36. Setting the two equal and collecting terms, 3b3−31b2−57b−36=0.3b^3 - 31b^2 - 57b - 36 = 0.

Only three bases need testing. The digits appearing are 11, 66, 55, 88, 99 and 00, so b≥10b \ge 10; and rearranging the cubic as b(3b2−31b−57)=36b\left(3b^2 - 31b - 57\right) = 36 shows that a whole number bb must divide 3636. The divisors of 3636 that are at least 1010 are 1212, 1818 and 3636.

Try b=12b = 12: 3×1728−31×144−57×12−36=5184−4464−684−36=03 \times 1728 - 31 \times 144 - 57 \times 12 - 36 = 5184 - 4464 - 684 - 36 = 0, so 1212 is a root. Dividing it out, 3b3−31b2−57b−36=(b−12)(3b2+5b+3),3b^3 - 31b^2 - 57b - 36 = (b - 12)(3b^2 + 5b + 3), and the quadratic factor has discriminant 25−36<025 - 36 < 0, so it has no real root at all. The only base is b=12b = 12, which is at least 1010 and larger than every digit used, so the sum of all possible values is 1212.

Answer 12

Solution: PRMO 2019, Q6

Key idea

A Pythagorean triple with all three entries single non-zero digits can only be 3,4,53,4,5, so there are just two numbers to factorise.

We need digits a,b,ca, b, c from 11 to 99 with a2+b2=c2a^2 + b^2 = c^2. There is no need to know anything about Pythagorean triples: the only squares in play are 1, 4, 9, 16, 25, 36, 49, 64, 81,1,\ 4,\ 9,\ 16,\ 25,\ 36,\ 49,\ 64,\ 81, and ask which is the sum of two others. The following table tests a<b<ca<b<c; checking a2<c2/2a^2<c^2/2 makes each unordered pair appear once: cc2−a2(1≤a<c/2)2338,5415,12524,21,16635,32,27,20748,45,40,33863,60,55,48,39980,77,72,65,56,45\begin{array}{c|l} c& c^2-a^2\quad(1\le a<c/\sqrt2)\\\hline 2&3\\ 3&8,5\\ 4&15,12\\ 5&24,21,16\\ 6&35,32,27,20\\ 7&48,45,40,33\\ 8&63,60,55,48,39\\ 9&80,77,72,65,56,45 \end{array} The only square in the right-hand column is 16=4216=4^2, in the row c=5c=5, with a=3a=3. Equal positive legs cannot work, since 2a2=c22a^2=c^2 would have an odd exponent of 22 on the left and an even one on the right. Thus the only possibilities are (a,b,c)=(3,4,5)(a,b,c)=(3,4,5) and (4,3,5)(4,3,5). So abc‾\overline{abc} is 345345 or 435435. Factorising, 345=3×5×23,435=3×5×29.345 = 3 \times 5 \times 23, \qquad 435 = 3 \times 5 \times 29. The largest prime factor appearing is 2929.

Answer 29

Solution: IOQM 2020, Q2

Key idea

Two readings of the same number in two different bases give two expressions in base ten, and setting them equal produces a quadratic that happens to factor.

The whole difficulty of a problem like this is remembering what a string of digits actually means. Writing 503503 in base bb is shorthand for 5b2+0⋅b+35b^2 + 0 \cdot b + 3, and writing 305305 in base b+2b+2 is shorthand for 3(b+2)2+0⋅(b+2)+53(b+2)^2 + 0 \cdot (b+2) + 5. Both expressions describe the same number NN, so we may set them against each other: 5b2+3=3(b+2)2+5=3b2+12b+17.5b^2 + 3 = 3(b+2)^2 + 5 = 3b^2 + 12b + 17.

Collecting terms leaves 2b2−12b−14=02b^2 - 12b - 14 = 0, and dividing through by 22 gives b2−6b−7=0b^2 - 6b - 7 = 0, which factors cleanly as (b−7)(b+1)=0(b-7)(b+1) = 0. Only one of these roots can be a base, since a base must be positive and must also exceed every digit written in it, and the digit 55 appears. That settles b=7b = 7.

From there the arithmetic is short. We have N=5⋅49+3=248N = 5 \cdot 49 + 3 = 248, and as a final check it is worth confirming that 248248 really is 305305 in base nine, which it is, since 3⋅81+5=2483 \cdot 81 + 5 = 248. The product of the digits of NN is therefore 2⋅4⋅8=642 \cdot 4 \cdot 8 = 64.

Answer 64

Solution: IOQM 2024, Q8

Key idea

Adding 11 changes the digit sum by 1−9k1 - 9k where kk is the number of trailing nines, so k≡4(mod5)k \equiv 4 \pmod 5; the smallest candidate therefore ends in exactly four nines.

The printed word “integer” leaves the domain implicit. We use the intended reading that nn is positive. If digit sums of negative integers were defined by ignoring their minus signs, there would be no smallest nn: every positive solution would give a negative one via n↦−n−1n\mapsto-n-1, and the positive constructions below continue without bound.

The carry can be seen in 2399+1=24002399+1=2400: two nines disappear and the preceding digit increases by one, so the digit sum changes by 1−2⋅91-2\cdot9. Now suppose nn ends in exactly kk nines. Adding 11 turns those kk nines into zeros and increases the preceding digit by 11, so S(n+1)=S(n)−9k+1.S(n+1) = S(n) - 9k + 1. Both digit sums are to be multiples of 55, so 9k−1≡0(mod5)9k - 1 \equiv 0 \pmod 5, that is 4k≡1(mod5)4k \equiv 1 \pmod 5, which gives k≡4(mod5)k \equiv 4 \pmod 5. In particular k=0k = 0 is impossible, and the smallest allowed value is k=4k = 4.

So nn ends in four nines: write n=104m+9999n = 10^4m + 9999 with m≥0m \ge 0 and the last digit of mm not equal to 99. Then S(n)=S(m)+36,S(n) = S(m) + 36, and requiring 5∣S(n)5 \mid S(n) gives S(m)≡4(mod5)S(m) \equiv 4 \pmod 5. This already rules out m=0m = 0, which would give n=9999n = 9999 with digit sum 3636, not a multiple of 55. We want the smallest such nn, hence the smallest such mm, and the digit sums of 1,2,3,41, 2, 3, 4 are 1,2,3,41, 2, 3, 4, so m=4m = 4 is the first that works.

Therefore n=49999n = 49999, and a check confirms it: S(49999)=40S(49999) = 40 and S(50000)=5S(50000) = 5, both divisible by 55. The first two digits are 44 and 99.

Answer 49

Solution: IOQM 2025 Part SEP, Q7

Key idea

The digit cc is determined by aa and bb, so the count is the number of pairs (a,b)(a,b) with a≥1a \ge 1 and a+b≤9a + b \le 9.

Once aa and bb are chosen, c=a+bc = a+b is forced, and the only requirement is that cc really is a digit, that is a+b≤9a + b \le 9. Also a≥1a \ge 1 because the number has three digits.

For each aa from 11 to 99 the digit bb may be anything from 00 to 9−a9-a, which is 10−a10-a choices. Summing, 9+8+7+⋯+1=45.9 + 8 + 7 + \cdots + 1 = 45.

Answer 45

Solution: IOQM 2026, Q9

Key idea

The smallest number has as few digits as possible and then the smallest leading digit it can, which leaves a single 11 followed by nines, and adding 11 carries through every nine.

A number with kk digits has digit sum at most 9k9k. Since 2026=9⋅225+12026 = 9 \cdot 225 + 1, a number with 225225 digits reaches at most 20252025, so NN has at least 226226 digits, and a 226226-digit number is smaller than any longer one.

Among the 226226-digit numbers with digit sum 20262026, the smallest is the one with the smallest leading digit. The other 225225 digits add up to at most 20252025, so the leading digit is at least 2026−2025=12026 - 2025 = 1, and it equals 11 only when the other digits are all 99. So N=199…9⏟225,N+1=200…0⏟225,N = 1\underbrace{99\ldots9}_{225}, \qquad N + 1 = 2\underbrace{00\ldots0}_{225}, and the leading digit of N+1N + 1 is 22.

Answer 2

Solution: IOQM 2026, Q14

Key idea

Reversing the digits leaves the middle digit where it was, so ∣A−B∣|A - B| is 9999 times the gap between the outer digits, and that gap is too small to bring in a prime larger than 77.

Write A=100a+10b+cA = 100a + 10b + c, so that B=100c+10b+aB = 100c + 10b + a. Then A−B=99a−99c=9⋅11⋅(a−c).A - B = 99a - 99c = 9 \cdot 11 \cdot (a - c). The digits are distinct and non-zero, so ∣a−c∣|a - c| is one of 1,2,…,81, 2, \ldots, 8, whose prime factors are among 22, 33, 55 and 77. Every ∣A−B∣|A - B| is therefore 1111 times a number whose prime factors are at most 77, and the largest prime factor is 1111, for instance ∣123−321∣=198=2⋅9⋅11|123 - 321| = 198 = 2 \cdot 9 \cdot 11.

Answer 11

Solution: PRMO 2013, Q6

Key idea

The smallest number with a given digit sum is nines with a smaller leading digit, and multiplying that by 55 and adding 20132013 causes almost no carrying.

To make a number small you want few digits, so you want every digit as large as possible. With digit sum 2013=9×223+62013 = 9 \times 223 + 6, that means 223223 nines and a leading 66: N=699⋯9⏟223=7×10223−1.N = 6\underbrace{99\cdots9}_{223} = 7 \times 10^{223} - 1. Nothing with 223223 digits or fewer can reach a digit sum of 20132013, since 9×223=20079 \times 223 = 2007, and with 224224 digits the leading digit is at least 2013−9⋅223=62013-9\cdot223=6. Equality forces all the remaining digits to be 99, so this really is the smallest.

Now compute, using the closed form: 5N+2013=35×10223−5+2013=35×10223+2008.5N + 2013 = 35 \times 10^{223} - 5 + 2013 = 35 \times 10^{223} + 2008. The first term is 3535 followed by 223223 zeros, and adding 20082008 only fills in the last four of those zeros, with no carrying at all. So the digits are 33, 55, then a long run of zeros, then 22, 00, 00, 88, and S(5N+2013)=3+5+2+0+0+8=18.S(5N + 2013) = 3 + 5 + 2 + 0 + 0 + 8 = 18.

Answer 18

Solution: PRMO 2013, Q20

Key idea

Count by bit position: each of the six positions is set in (52)=10\binom52 = 10 of the twenty numbers.

A bit is a binary digit, 00 or 11. For example, 001011001011 represents 8+2+1=118+2+1=11 and has three ones; leading zeros let every number below 6464 use six positions. A natural number below 6464 is therefore a six-bit string, and we want those with exactly three ones, of which there are (63)=20\binom63 = 20.

Rather than list them, count each bit’s contribution. A given position is a one in exactly those strings whose other two ones are chosen from the remaining five positions, that is (52)=10\binom52 = 10 of them. So each position contributes its place value ten times, and the total is 10×(1+2+4+8+16+32)=10×63=630.10 \times (1 + 2 + 4 + 8 + 16 + 32) = 10 \times 63 = 630.

The same argument gives the sum for any number of ones: with jj ones among mm bits the total is (m−1j−1)(2m−1)\binom{m-1}{j-1}\left(2^m - 1\right).

Answer 630

Solution: PRMO 2015 Part A, Q20

Key idea

Every such number is 1111d+32101111d + 3210 for a digit dd, and 11111111 leaves remainder 11 on division by 3737, so the seven remainders are seven consecutive integers.

Let the digits be d+3,d+2,d+1,dd+3, d+2, d+1, d read from the left, where d≥0d \ge 0 and d+3≤9d + 3 \le 9, so dd runs from 00 to 66 and there are seven such numbers. Their values are n=1000(d+3)+100(d+2)+10(d+1)+d=1111d+3210.n = 1000(d+3) + 100(d+2) + 10(d+1) + d = 1111d + 3210.

Both constants behave well modulo 3737. Since 37×30=111037 \times 30 = 1110, we have 1111≡11111 \equiv 1, and since 37×86=318237 \times 86 = 3182, we have 3210≡283210 \equiv 28. Therefore n≡d+28(mod37).n \equiv d + 28 \pmod{37}. As dd runs from 00 to 66 the right-hand side runs from 2828 to 3434, all of which are already between 00 and 3636, so they are the remainders themselves and they are seven distinct values. Their sum is 28+29+30+31+32+33+34=7(28+34)2=217.28 + 29 + 30 + 31 + 32 + 33 + 34 = \frac{7(28+34)}{2} = 217.

The reason 3737 appears rather than some other modulus is that 3737 divides 111111, and therefore divides 11101110, which is what makes 11111111 leave the convenient remainder 11. A problem that pairs repdigit-like numbers with the modulus 3737 is nearly always leaning on that fact.

Answer 217

Solution: PRMO 2017, Q1

Key idea

Divisibility by 33 is itself a statement about the digit sum, so the two conditions collapse into one: the digit sum is a multiple of 2121, and only 2121 itself is small enough.

the number 768 , whose digits sum to 21
the number 768768, whose digits sum to 2121

A number is divisible by 33 exactly when its digit sum is, so the two conditions together say that the digit sum is divisible by both 77 and 33, that is by 2121.

A number below 10001000 has at most three digits, so its digit sum is at most 2727. The only positive multiple of 2121 available is 2121 itself, and the digit sum is positive because the number is.

So we must count the numbers below 10001000 whose digits sum to 2121. Write every such number with three digits, padding with leading zeros, which changes nothing: a number with fewer digits has digit sum at most 1818, so none is lost. We need a+b+c=21,0≤a,b,c≤9.a + b + c = 21, \qquad 0 \le a, b, c \le 9. Replace each digit by its complement, a′=9−aa' = 9 - a and so on. Then a′+b′+c′=27−21=6a' + b' + c' = 27 - 21 = 6 with each a′,b′,c′≥0a', b', c' \ge 0, and the upper bound of 99 is automatic since the total is only 66. Counting those is the standard stars and bars: lay out six stars in a row and choose two of the eight positions in the resulting line of stars and bars to be the bars, which cuts the six into three groups. So the number of solutions is (6+22)=(82)=28.\binom{6 + 2}{2} = \binom{8}{2} = 28.

Answer 28

Solution: PRMO 2018, Q20

Key idea

The product of the digits of nn lies between 00 and nn, and the two inequalities that follow leave room for exactly one integer.

For a one-digit example, the product of the digits of 77 is 77; for 7272 it is 7⋅2=14<727\cdot2=14<72. The leading digit has its full place value in the number, while the digit product only multiplies it by the smaller remaining digits. This suggests bounding the product by the number itself.

Write P(n)P(n) for the product of the digits. Two facts bound it. It is at least 00, and it is at most nn: for a one-digit number the two are equal, and for a number with more digits the leading digit alone contributes at least 10k10^{k} times itself while the product of the rest is at most 9k9^k, so P(n)<nP(n) < n.

Applying both to P(n)=n2−15n−27P(n) = n^2 - 15n - 27: n2−15n−27≥0andn2−16n−27≤0.n^2 - 15n - 27 \ge 0 \qquad \text{and} \qquad n^2 - 16n - 27 \le 0. Each quadratic changes sign once in the range of interest, so integer tests settle both without a square root. The first is −11-11 at n=16n = 16 and 77 at n=17n = 17, so n≥17n \ge 17; the second is −10-10 at n=17n = 17 and 99 at n=18n = 18, so n≤17n \le 17. So n=17n = 17 is the only candidate, and it works: P(17)=7P(17) = 7 and 172−15⋅17−27=289−255−27=717^2 - 15 \cdot 17 - 27 = 289 - 255 - 27 = 7.

The sum of all such nn is therefore 1717.

Answer 17

Solution: IOQM 2020, Q8

Key idea

One of the five digits is 3k3k, and a digit can never exceed 99, so there are only three numbers in the world to test.

Problems that describe a number through its digits are usually solved by asking what the digits are permitted to be, rather than by any clever algebra. Here the five digits are kk, k+1k+1, k+2k+2, 3k3k and k+3k+3, and each of them must be a single digit lying between 00 and 99, while the leading digit kk must also be non-zero because the number has five digits.

The binding restriction is the fourth digit. Requiring 3k≤93k \leq 9 forces k≤3k \leq 3, and combined with k≥1k \geq 1 this leaves only three candidates, which we may write out in full: k=1:  12334,k=2:  23465,k=3:  34596.k=1: \; 12334, \qquad k=2: \; 23465, \qquad k=3: \; 34596.

Testing each is now a matter of locating it between neighbouring squares. Since 1112=12321111^2 = 12321 and 1122=12544112^2 = 12544, the first candidate is not a square. Since 1532=23409153^2 = 23409 and 1542=23716154^2 = 23716, neither is the second. The third is a square exactly, because 1862=34596186^2 = 34596.

So m=186m = 186, and the sum of its digits is 1+8+6=151 + 8 + 6 = 15.

Answer 15

Solution: IOQM 2021 Part A, Q4

Key idea

By symmetry each of the three digits occupies each of the six places equally often, so the enormous sum factors as 35⋅111111⋅(a+b+c)3^5 \cdot 111111 \cdot (a+b+c) and reveals only the digit sum.

First rule out a zero among the three digits, since a zero cannot lead and the counting below would not be symmetric. If the digits are 00, pp, qq, then the leading place must carry pp or qq, and there are 2⋅35=4862 \cdot 3^5 = 486 numbers. Each of pp and qq heads 35=2433^5 = 243 of them, while in each of the five lower places every one of the three digits appears 2⋅34=1622 \cdot 3^4 = 162 times. The total is therefore (243⋅100000+162⋅11111)(p+q)=26099982 (p+q).\bigl(243 \cdot 100000 + 162 \cdot 11111\bigr)(p+q) = 26099982\,(p+q). Since pp and qq are distinct non-zero digits, p+q≤17p + q \leq 17, and the total is at most 26099982⋅17=44369969426099982 \cdot 17 = 443699694. That falls short of 593999406593999406, so none of the digits is zero.

With all three digits non-zero, there are 36=7293^6 = 729 six-digit numbers built from aa, bb and cc. Fix one place, say the leading one. Of those 729729, exactly a third have aa there, a third have bb and a third have cc, so each digit appears 35=2433^5 = 243 times in that place, and by symmetry the same is true of every place.

Summing over all six places, each of which is worth its place value, gives 243⋅(a+b+c)⋅(100000+10000+⋯+1)=243⋅111111⋅(a+b+c),243 \cdot (a+b+c) \cdot (100000 + 10000 + \cdots + 1) = 243 \cdot 111111 \cdot (a+b+c), which is 26999973 (a+b+c)26999973\,(a+b+c). Setting this equal to 593999406593999406 and dividing, a+b+c=22a + b + c = 22. Notice how little the huge number actually told us: only the digit sum, and nothing about which digit is which.

That leaves an optimisation. We want the largest remainder of the three-digit number abc‾\overline{abc} on division by 100100, which is just the two-digit ending bc‾\overline{bc}, so we want 10b+c10b + c as large as possible subject to a,b,ca, b, c being distinct digits summing to 2222 with a≠0a \neq 0. Taking b=9b = 9 and c=8c = 8 gives a=5a = 5, and all three are distinct, so bc‾=98\overline{bc} = 98 is attainable. Nothing larger is possible, since b=9,c=9b = 9, c = 9 would repeat a digit.

Answer 98

Solution: IOQM 2024, Q21

Key idea

The second condition forces nn to be around 80008000 to 1700017000, and the first caps nn below 90009000; between them only the repeated digit 999999 survives, and that leaves a range of nine integers to test.

If ⌊n/9⌋\lfloor n/9 \rfloor is the three-digit repeated-digit number ddd‾\overline{ddd}, then 9⋅ddd‾≤n≤9⋅ddd‾+8,9 \cdot \overline{ddd} \le n \le 9 \cdot \overline{ddd} + 8, so n≤9⋅999+8=9000−1n \le 9 \cdot 999 + 8 = 9000 - 1.

The second condition says ⌊(n−172)/4⌋\lfloor (n-172)/4 \rfloor is a rearrangement of the digits 2,0,2,42, 0, 2, 4, and every such four-digit number is at least 20242024. Hence n−172≥4⋅2024,n≥8268.n - 172 \ge 4 \cdot 2024, \qquad n \ge 8268.

Combining, 8268≤n≤89998268 \le n \le 8999, and the only repeated-digit multiple in range is ddd‾=999\overline{ddd} = 999, giving 8991≤n≤8999.8991 \le n \le 8999. For those values n−172n - 172 runs from 88198819 to 88278827, so ⌊(n−172)/4⌋\lfloor (n-172)/4 \rfloor is 22042204, 22052205 or 22062206. Only 22042204 uses the digits 2,0,2,42, 0, 2, 4.

Finally, ⌊(n−172)/4⌋=2204\lfloor (n-172)/4 \rfloor = 2204 means 8816≤n−172≤88198816 \le n - 172 \le 8819, that is 8988≤n≤89918988 \le n \le 8991. Intersecting with the earlier range leaves the single value n=8991,n = 8991, and the remainder on division by 100100 is 9191.

Answer 91

Solution: IOQM 2025 Part SEP, Q28

Key idea

The exponents available are the distinct powers of two, so the binary expansion of 20252025 says exactly which brackets give xx, and the rest give their constants.

In the first three brackets, a term x5x^5 must take xx from the first and x4x^4 from the third, because 5=4+15=4+1; the middle bracket contributes its constant 33. The same binary choice controls the much larger exponent in the question.

Each bracket contributes either its power of xx or its constant. The powers on offer are x1,x2,x4,…,x1024x^{1}, x^{2}, x^{4}, \ldots, x^{1024}, that is x2kx^{2^k} for k=0,1,…,10k = 0, 1, \ldots, 10, and the constant in the bracket with x2kx^{2^k} is 2k+12k+1.

Choosing a set SS of brackets to supply their power of xx produces the exponent ∑k∈S2k\sum_{k \in S} 2^k, and by the uniqueness of binary representation there is exactly one SS giving 20252025. Writing it out, 2025=1024+512+256+128+64+32+8+1,2025 = 1024 + 512 + 256 + 128 + 64 + 32 + 8 + 1, so S={0,3,5,6,7,8,9,10}S = \{0, 3, 5, 6, 7, 8, 9, 10\} and the brackets left over are those with k=1,2,4k = 1, 2, 4.

Their constants are 33, 55 and 99, so N=3⋅5⋅9=135,N = 3 \cdot 5 \cdot 9 = 135, and the remainder on division by 100100 is 3535.

Answer 35

Solution: IOQM 2025 Part SEP, Q28

Key idea

ababab‾=10101⋅ab‾\overline{ababab} = 10101 \cdot \overline{ab} and 10101=3⋅7⋅13⋅3710101 = 3 \cdot 7 \cdot 13 \cdot 37, so the product of three consecutive odd numbers is pinned down to a narrow range and 35⋅37⋅3935 \cdot 37 \cdot 39 is the only candidate that works.

By place value, ababab‾=ab‾⋅10101,10101=3⋅7⋅13⋅37.\overline{ababab} = \overline{ab} \cdot 10101, \qquad 10101 = 3 \cdot 7 \cdot 13 \cdot 37. So the equation reads 5(2m+1)(2m+3)(2m+5)=10101 t,t=ab‾.5(2m+1)(2m+3)(2m+5) = 10101\,t, \qquad t = \overline{ab}. Since 55 divides the left side but not 1010110101, the two-digit number tt is a multiple of 55.

Now bound mm exactly. At m=12m = 12 the left side is 5⋅25⋅27⋅29=978755 \cdot 25 \cdot 27 \cdot 29 = 97875, still five digits, and at m=13m = 13 it is 5⋅27⋅29⋅31=1213655 \cdot 27 \cdot 29 \cdot 31 = 121365. At the other end m=27m = 27 gives 5⋅55⋅57⋅59=9248255 \cdot 55 \cdot 57 \cdot 59 = 924825, while m=28m = 28 gives 10257151025715, which has seven digits. The left side increases with mm, so 13≤m≤27,and hence27≤2m+1<2m+5≤59.13 \leq m \leq 27, \qquad \text{and hence} \qquad 27 \leq 2m+1 < 2m+5 \leq 59.

Rather than test fifteen values, use the factor 3737: it must divide one of the three consecutive odd numbers, and the only multiple of 3737 between 2727 and 5959 is 3737 itself. So one of 2m+1,2m+3,2m+52m+1, 2m+3, 2m+5 equals 3737, and the three possibilities are 33⋅35⋅37,35⋅37⋅39,37⋅39⋅41.33 \cdot 35 \cdot 37, \qquad 35 \cdot 37 \cdot 39, \qquad 37 \cdot 39 \cdot 41. Multiplying by 55 gives 213675213675, 252525252525 and 295815295815, and only the middle one has the required form, ababab‾\overline{ababab} with a=2a = 2 and b=5b = 5.

That case is 2m+1=352m+1 = 35, so m=17m = 17, and m+a+b=17+2+5=24.m + a + b = 17 + 2 + 5 = 24.

Answer 24

Solution: IOQM 2025 Part SEP, Q7

Key idea

Writing M=ab‾M = \overline{ab}, the number is 1001M+100c1001M + 100c, so divisibility by MM says M∣100cM \mid 100c, and 1001=7⋅11⋅131001 = 7 \cdot 11 \cdot 13 makes the condition about 1313 say only that c≠0c \ne 0.

Expanding by place value, abcab‾=(10a+b)⋅1000+100c+(10a+b)=1001M+100c,\overline{abcab} = (10a+b)\cdot 1000 + 100c + (10a+b) = 1001M + 100c, where M=ab‾M = \overline{ab}.

Two conditions follow. Since MM divides 1001M1001M, divisibility of the number by MM says exactly M∣100c.M \mid 100c. And since 13∣100113 \mid 1001, the number is congruent to 100c≡9c(mod13)100c \equiv 9c \pmod{13}, so it fails to be divisible by 1313 exactly when 13∤9c13 \nmid 9c, that is when c≠0c \ne 0.

We want to maximise the digit sum 2(a+b)+c2(a+b) + c, where a+ba + b is the digit sum of MM. For each value of cc from 11 to 99, take the two-digit divisor of 100c100c whose own digit sum is largest. The candidate divisors and their best digit sums can be checked row by row: ctwo-digit divisors of 100cbest M2(a+b)+c110,20,25,502515210,20,25,40,502516310,12,15,20,25,30,50,60,757527410,16,20,25,40,50,808020510,20,25,502519610,12,15,20,24,25,30,40,50,60,757530710,14,20,25,28,35,50,702827810,16,20,25,32,40,50,808024910,12,15,18,20,25,30,36,45,50,60,75,907533\begin{array}{c|l|c|c} c&\text{two-digit divisors of }100c&\text{best }M&2(a+b)+c\\\hline 1&10,20,25,50&25&15 \\ 2&10,20,25,40,50&25&16 \\ 3&10,12,15,20,25,30,50,60,75&75&27 \\ 4&10,16,20,25,40,50,80&80&20 \\ 5&10,20,25,50&25&19 \\ 6&10,12,15,20,24,25,30,40,50,60,75&75&30 \\ 7&10,14,20,25,28,35,50,70&28&27 \\ 8&10,16,20,25,32,40,50,80&80&24 \\ 9&10,12,15,18,20,25,30,36,45,50,60,75,90&75&33 \\ \end{array} Every value of cc is there, so nothing is left to check. The winner is M=75M = 75 with c=9c = 9, giving the number 7597575975.

Both conditions check out: 75975=75⋅101375975 = 75 \cdot 1013, and 75975=13⋅5844+375975 = 13 \cdot 5844 + 3. Its digit sum is 7+5+9+7+5=337+5+9+7+5 = 33.

Answer 33

Solution: IOQM 2026, Q20

Key idea

Moving the 33 from the front to the back turns M=3⋅10k+xM = 3 \cdot 10^k + x into 10x+310x + 3, and the condition becomes 13x=10k−413x = 10^k - 4. So the question is the first power of 1010 that leaves remainder 44 on division by 1313.

Say MM has k+1k + 1 digits, and write M=3⋅10k+xM = 3 \cdot 10^k + x, where xx is the number formed by the other kk digits. Moving the 33 to the end gives N=10x+3N = 10x + 3, and M=4NM = 4N reads 3⋅10k+x=40x+12,39x=3⋅10k−12,13x=10k−4.3 \cdot 10^k + x = 40x + 12, \qquad 39x = 3 \cdot 10^k - 12, \qquad 13x = 10^k - 4.

So 10k10^k must leave remainder 44 on division by 1313. Each remainder is 1010 times the one before, reduced: 101→10,102→9,103→12,104→3,105→4.10^1 \to 10, \quad 10^2 \to 9, \quad 10^3 \to 12, \quad 10^4 \to 3, \quad 10^5 \to 4. The first success is k=5k = 5, with x=99996/13=7692x = 99996/13 = 7692, so M=307692,N=76923,4×76923=307692.M = 307692, \qquad N = 76923, \qquad 4 \times 76923 = 307692.

The five digits after the 33 are 0,7,6,9,20, 7, 6, 9, 2, so the rearranged six-digit string is 076923076923, representing the number N=76923N=76923. The condition N=M/4N = M/4 holds all the same, and there is no way round it: x=(10k−4)/13x = (10^k - 4)/13 is less than 10k−110^{k-1}, so the second digit of MM is 00 for every kk that works. The sum of the digits of MM is 3+0+7+6+9+2=273 + 0 + 7 + 6 + 9 + 2 = 27.

Answer 27

Solution: PRMO 2018, Q19

Key idea

NN is 227(10101−910)\tfrac{2}{27}(10^{101} - 910), and 2727 times the number 740740…7407740740\ldots7407 is 2⋅10101−112 \cdot 10^{101} - 11, so NN is that number minus 6767.

The first few partial sums are 66, 7272, 738738, 74047404 and 7407074070. They suggest a repeating block near the front, so a closed form is useful for exposing the digits of the hundred-term sum.

A closed form

Each term is 66⋯6⏟k=23(10k−1)\underbrace{66\cdots6}_{k} = \tfrac23(10^k - 1), so N=23∑k=1100(10k−1)=23(10101−109−100),N = \frac23\sum_{k=1}^{100}\left(10^k - 1\right) = \frac23\left(\frac{10^{101} - 10}{9} - 100\right), which tidies up to N=227(10101−910)N = \tfrac{2}{27}\left(10^{101} - 910\right).

The digits

Let AA be the number written as thirty-three copies of the block 740740 followed by a final 77, so AA has 100100 digits. Summing the geometric series inside it, A=7400⋅1099−1999+7.A = 7400 \cdot \frac{10^{99} - 1}{999} + 7. Multiplying by 2727 and using 199800=200×999199800 = 200 \times 999, 27A=200(1099−1)+189=2⋅10101−11.27A = 200\left(10^{99}-1\right) + 189 = 2 \cdot 10^{101} - 11. Therefore 27N=2⋅10101−1820=(27A+11)−1820=27A−1809,27N = 2 \cdot 10^{101} - 1820 = \left(27A + 11\right) - 1820 = 27A - 1809, and since 1809=27×671809 = 27 \times 67, N=A−67.N = A - 67.

The subtraction touches only the last four digits. AA ends in 74077407, and 7407−67=73407407 - 67 = 7340, so N=740 740 ⋯ 740⏟32 blocks 7340,N = \underbrace{740\,740\,\cdots\,740}_{32 \text{ blocks}}\,7340, a hundred digits in all.

Counting the sevens

Each of the 3232 blocks contributes one 77, and the tail 73407340 contributes one more: 32+1=33.32 + 1 = 33.

Answer 33

Solution: PRMO 2018, Q30

Key idea

Non-negative coefficients summing to 44 are all at most 44, so P(5)=136P(5) = 136 is nothing but the base-five expansion of 136136.

Since the coefficients are non-negative integers and P(1)=∑ai=4P(1) = \sum a_i = 4, every coefficient is at most 44. That is precisely the condition for the digits of a base-five numeral, and P(5)=∑iai5i=136P(5) = \sum_i a_i 5^i = 136 says that the coefficients are the base-five digits of 136136.

Expand 136136 in base five: 136=125+11=1⋅53+0⋅52+2⋅5+1136 = 125 + 11 = 1 \cdot 5^3 + 0 \cdot 5^2 + 2 \cdot 5 + 1, so 136=1021 5,P(x)=x3+2x+1.136 = 1021_{\,5}, \qquad P(x) = x^3 + 2x + 1. As a check, the digits do sum to 1+0+2+1=4=P(1)1 + 0 + 2 + 1 = 4 = P(1), as they must, and base-five expansions are unique, so this is the only such polynomial.

Hence P(3)=27+6+1=34.P(3) = 27 + 6 + 1 = 34.

Answer 34

Solution: IOQM 2023, Q19

Key idea

A squarefree product forbids the digits 44, 88 and 99 and forbids repeating any prime, so P(n)≤2⋅3⋅5⋅7=210P(n) \le 2 \cdot 3 \cdot 5 \cdot 7 = 210; the digits are then almost all ones, and their count is fixed by making S(n)S(n) the largest proper divisor of P(n)P(n).

The digits of 23572357 have product 210210 and sum 1717. Prefixing a 11 gives 1235712357, with the same product and sum 1818. Ones therefore add length without changing the product, which is the resource to exploit.

Since P(n)≠0P(n) \ne 0, no digit is 00. Since P(n)P(n) is squarefree, no prime may occur twice in the product of the digits. That rules out the digits 4=224 = 2^2, 8=238 = 2^3 and 9=329 = 3^2 outright, and it also means that among the remaining digits 2,3,5,6,72, 3, 5, 6, 7 we may use each prime once only. In particular P(n)≤2⋅3⋅5⋅7=210,P(n) \le 2 \cdot 3 \cdot 5 \cdot 7 = 210, with equality when the non-unit digits are 2,3,5,72, 3, 5, 7 (or 6,5,76, 5, 7, since 6=2⋅36 = 2 \cdot 3).

Digits equal to 11 change nothing in the product and add 11 each to the sum, so they are the way to make a number long. Suppose the non-unit digits have product pp and sum tt, and there are kk ones. Then P(n)=p,S(n)=k+t,P(n) = p, \qquad S(n) = k + t, and the requirement is that k+tk+t is a proper divisor of pp. The number of digits is k+(number of non-unit digits)k + (\text{number of non-unit digits}), so for a fixed set of non-unit digits we want kk as large as possible, that is k+tk + t as large as possible, and the largest proper divisor available is pp divided by its smallest prime factor.

Take p=210p = 210 with non-unit digits 2,3,5,72, 3, 5, 7, so t=17t = 17 and there are four of them. The largest proper divisor of 210210 is 105105, so k=105−17=88k = 105 - 17 = 88 and the number has 88+4=9288 + 4 = 92 digits. The number consisting of 8888 ones followed by 2,3,5,72, 3, 5, 7 has digit sum 88+17=10588 + 17 = 105, digit product 210210, and 105105 is indeed a proper divisor of 210210.

Every other choice is shorter. At p=210p = 210 the only other grouping of the digits is 6,5,76, 5, 7, which raises tt to 1818 and drops to three non-unit digits, giving 87+3=9087 + 3 = 90.

Every smaller pp falls far short, and a single bound covers all of them at once. The admissible products are the divisors of 210210, so p<210p < 210 means p≤105p \le 105. Write D=S(n)D = S(n), a proper divisor of pp, so that D≤p/2≤52D \le p/2 \le 52. If there are rr non-unit digits with sum tt, then t≥2rt \ge 2r, since each such digit is at least 22, and the number of digits is (D−t)+r  ≤  D−2r+r  =  D−r  ≤  51.(D - t) + r \;\le\; D - 2r + r \;=\; D - r \;\le\; 51. That is nowhere near 9292, so the maximum is 9292.

Answer 92

Solution: IOQM 2023, Q26

Key idea

Splitting on whether the number of one-Ben notes is 00, 11 or 22 turns the count into the recursion f(2k)=f(k)+f(k−1)f(2k) = f(k) + f(k-1), f(2k+1)=f(k)f(2k+1) = f(k), and 100100 unwinds in a few lines.

Let f(N)f(N) be the number of ways to pay NN Bens using notes of value 1,2,4,8,…1, 2, 4, 8, \ldots with at most two of each. Look at how many one-Ben notes are used. That number has the same parity as NN and is at most 22, so it is forced up to one choice:

If NN is odd, exactly one one-Ben note is used, and the rest, N−1N - 1, is paid in notes of value at least 22; halving every note turns this into a payment of N−12\tfrac{N-1}2 under the same rules. If NN is even, either no one-Ben note is used, giving a payment of N2\tfrac N2 after halving, or two are used, giving N2−1\tfrac{N}{2} - 1. Hence f(2k+1)=f(k),f(2k)=f(k)+f(k−1),f(2k+1) = f(k), \qquad f(2k) = f(k) + f(k-1), with f(0)=1f(0) = 1 and f(1)=1f(1) = 1.

A check against the problem’s own examples: f(2)=f(1)+f(0)=2f(2) = f(1) + f(0) = 2 and f(5)=f(2)=2f(5) = f(2) = 2, both as stated.

Now unwind f(100)f(100), keeping only what is needed: f(100)=f(50)+f(49),f(50)=f(25)+f(24),f(49)=f(24),f(25)=f(12),f(24)=f(12)+f(11),f(12)=f(6)+f(5),f(11)=f(5),f(6)=f(3)+f(2)=1+2=3,f(5)=f(2)=2.\begin{aligned} f(100) &= f(50) + f(49), \\ f(50) &= f(25) + f(24), \qquad f(49) = f(24), \\ f(25) &= f(12), \qquad f(24) = f(12) + f(11), \\ f(12) &= f(6) + f(5), \qquad f(11) = f(5), \\ f(6) &= f(3) + f(2) = 1 + 2 = 3, \qquad f(5) = f(2) = 2. \end{aligned} Working back up: f(12)=5f(12) = 5, f(11)=2f(11) = 2, f(25)=5f(25) = 5, f(24)=7f(24) = 7, f(50)=12f(50) = 12, f(49)=7f(49) = 7, and finally f(100)=12+7=19.f(100) = 12 + 7 = 19.

Answer 19

Solution: IOQM 2025 Part SEP, Q28

Key idea

Subtracting one from every digit turns the two conditions into (a−1)(c−1)+(b−1)(d−1)=2(a-1)(c-1) + (b-1)(d-1) = 2, and a sum of two non-negative products equal to 22 has only three splits.

Adding the two conditions compares ac+bdac+bd with a+b+c+da+b+c+d. Subtracting the matching linear terms makes ac−a−cac-a-c and bd−b−dbd-b-d, each one short of a product of non-negative integers. Complete those products by adding 11 to each: (a−1)(c−1)=ac−(a+c)+1=ac−bd+1,(a-1)(c-1) = ac - (a+c) + 1 = ac - bd + 1, (b−1)(d−1)=bd−(b+d)+1=bd−ac+1.(b-1)(d-1) = bd - (b+d) + 1 = bd - ac + 1. Adding, everything cancels except the constants: (a−1)(c−1)+(b−1)(d−1)=2.(a-1)(c-1) + (b-1)(d-1) = 2.

Every digit is at least 11, so both products are non-negative integers, and there are exactly three ways to split 22.

The split 1+11 + 1

Then (a−1)(c−1)=1(a-1)(c-1) = 1 forces a=c=2a = c = 2, and likewise b=d=2b = d = 2. Both conditions hold, since 2+2=2⋅22 + 2 = 2 \cdot 2. This is the single number 22222222.

The split 0+20 + 2

Then one of a,ca, c is 11, and (b−1)(d−1)=2(b-1)(d-1) = 2 makes {b,d}={2,3}\{b,d\} = \{2,3\}. So bd=6bd = 6, and a+c=6a + c = 6 gives the other of a,ca, c as 55. The remaining condition b+d=acb + d = ac reads 5=55 = 5, so it holds. That is {a,c}={1,5}\{a,c\} = \{1,5\} with {b,d}={2,3}\{b,d\} = \{2,3\}: two orders for each pair, hence 2⋅2=42 \cdot 2 = 4 numbers, 1253,1352,5213,5312.1253, \quad 1352, \quad 5213, \quad 5312.

The split 2+02 + 0

The same argument with the roles reversed, which the conditions permit because swapping the pair (a,c)(a,c) with the pair (b,d)(b,d) leaves them unchanged. Here {a,c}={2,3}\{a,c\} = \{2,3\} and {b,d}={1,5}\{b,d\} = \{1,5\}, giving 21352135, 25312531, 31253125 and 35213521.

The three splits are exhaustive, so the total is 4+4+1=9.4 + 4 + 1 = 9.

Answer 9

Report an error on this page

Reports are stored by Netlify. See the privacy note.