Library · Between the Challenge and the Olympiad · Chapter 2

Divisibility, Primes and Congruences

Revised Report an error
On this page
  1. Problems
  2. Solutions
  3. Solution: PRMO 2013, Q1
  4. Solution: PRMO 2014, Q1
  5. Solution: IOQM 2024, Q1
  6. Solution: IOQM 2025 Part SEP, Q7
  7. Solution: IOQM 2025 Part SEP, Q28
  8. Solution: IOQM 2026, Q2
  9. Solution: PRMO 2015 Part A, Q4
  10. Solution: PRMO 2019, Q4
  11. Solution: PRMO 2019, Q14
  12. Solution: IOQM 2020, Q6
  13. Solution: IOQM 2020, Q17
  14. Solution: IOQM 2021 Part A, Q3
  15. Solution: IOQM 2023, Q6
  16. Solution: PRMO 2012, Q11
  17. Solution: PRMO 2012, Q16
  18. Solution: PRMO 2013, Q18
  19. Solution: PRMO 2014, Q11
  20. Solution: PRMO 2014, Q13
  21. Solution: PRMO 2015 Part A, Q13
  22. Solution: PRMO 2018, Q22
  23. Solution: PRMO 2019, Q21
  24. Solution: IOQM 2020, Q14
  25. Solution: IOQM 2020, Q28
  26. Solution: IOQM 2022, Q7
  27. Solution: IOQM 2023, Q9
  28. Solution: IOQM 2024, Q29
  29. Solution: IOQM 2026, Q25
  30. Solution: PRMO 2014, Q17
  31. Solution: PRMO 2014, Q18
  32. Solution: PRMO 2017, Q28
  33. Solution: PRMO 2017, Q29
  34. Solution: PRMO 2018, Q25
  35. Solution: PRMO 2019, Q12
  36. Solution: PRMO 2019, Q18
  37. Solution: PRMO 2019, Q30
  38. Solution: IOQM 2020, Q25
  39. Solution: IOQM 2021 Part B, Q2
  40. Solution: IOQM 2022, Q8
  41. Solution: IOQM 2022, Q17
  42. Solution: IOQM 2022, Q18
  43. Solution: IOQM 2023, Q29
  44. Solution: IOQM 2023, Q30
  45. Solution: IOQM 2024, Q18
  46. Solution: IOQM 2024, Q23
  47. Solution: IOQM 2024, Q28
  48. Solution: IOQM 2026, Q29
  49. Solution: PRMO 2019, Q20
  50. Solution: IOQM 2020, Q30

Problems

Problem 1

What is the smallest positive integer kk such that k(33+43+53)=ank(3^3 + 4^3 + 5^3) = a^n for some positive integers aa and nn, with n>1n > 1?

Problem 2

A natural number kk is such that k2<2014<(k+1)2k^2 < 2014 < (k+1)^2. What is the largest prime factor of kk?

Problem 3

The smallest positive integer that does not divide 1×2×3×4×5×6×7×8×91 \times 2 \times 3 \times 4 \times 5 \times 6 \times 7 \times 8 \times 9 is:

Problem 4

Find the number of positive integers nn less than or equal to 100100, which are divisible by 33 but are not divisible by 22.

Problem 5

Find the number of positive integers nn less than or equal to 100 such that nn is not divisible by any prime number other than 2 or 3.

Problem 6

An integer MM is divisible by 44 but not by 256256. What is the number of distinct possible remainders when MM is divided by 256256?

Problem 7

Let P(x)P(x) be a non-zero polynomial with integer coefficients. If P(n)P(n) is divisible by nn for each positive integer nn, what is the value of P(0)P(0)?

Problem 8

An ant leaves the anthill for its morning exercise. It walks 44 feet east and then makes a 160∘160^\circ turn to the right and walks 44 more feet. It then makes another 160∘160^\circ turn to the right and walks 44 more feet. If the ant continues this pattern until it reaches the anthill again, what is the distance in feet it would have walked?

Problem 9

Find the smallest positive integer n≥10n \geq 10 such that n+6n + 6 is a prime and 9n+79n + 7 is a perfect square.

Problem 10

What is the least positive integer by which 25⋅36⋅43⋅53⋅672^5 \cdot 3^6 \cdot 4^3 \cdot 5^3 \cdot 6^7 should be multiplied so that the product is a perfect square?

Problem 11

How many two digit numbers have exactly 4 positive factors? (Here 1 and the number nn are also considered as factors of nn.)

Problem 12

Consider the set T\mathcal{T} of all triangles whose sides are distinct prime numbers which are also in arithmetic progression. Let △∈T\triangle \in \mathcal{T} be the triangle with the least perimeter. If a∘a^{\circ} is the largest angle of △\triangle and if LL is its perimeter, determine the value of aL\dfrac{a}{L}.

Problem 13

Let XX be the set of all even positive integers nn such that the measure of the angle of some regular polygon is nn degrees. Find the number of elements in XX.

Problem 14

The sum of four distinct prime numbers is 240. If none of the four primes is greater than 70, what is the smallest of the four numbers?

Problem 15

How many positive integers n≤100n \leq 100 are divisible by all positive integers ii such that i3≤ni^3 \leq n?

Problem 16

Let P(n)=(n+1)(n+3)(n+5)(n+7)(n+9)P(n) = (n+1)(n+3)(n+5)(n+7)(n+9). What is the largest integer that is a divisor of P(n)P(n) for all positive even integers nn?

Problem 17

Let NN be the set of natural numbers. Suppose f:N→Nf : N \to N is a function satisfying the following conditions.

(a) f(mn)=f(m)f(n)f(mn) = f(m)f(n);

(b) f(m)<f(n)f(m) < f(n) if m<nm < n;

(c) f(2)=2f(2) = 2.

What is the value of ∑k=120f(k)\sum_{k=1}^{20} f(k)?

Problem 18

What is the maximum possible value of kk for which 2013 can be written as a sum of kk consecutive positive integers?

Problem 19

For natural numbers xx and yy, let (x,y)(x, y) denote the greatest common divisor of xx and yy. How many pairs of natural numbers xx and yy with x≤yx \le y satisfy the equation xy=x+y+(x,y)xy = x + y + (x, y)?

Problem 20

For how many natural numbers nn between 11 and 20142014 (both inclusive) is 8n9999−n\dfrac{8n}{9999 - n} an integer?

Problem 21

Let nn be the largest integer that is the product of exactly 3 distinct prime numbers, xx, yy and 10x+y10x + y, where xx and yy are digits. What is the sum of the digits of nn?

Problem 22

A positive integer kk is said to be good if there exists a partition of {1,2,3,…,20}\{1, 2, 3, \ldots, 20\} into disjoint proper subsets such that the sum of the numbers in each subset of the partition is kk. How many good numbers are there?

Problem 23

Consider the set E={5,6,7,8,9}E = \{5, 6, 7, 8, 9\}. For any partition {A,B}\{A, B\} of EE, with both AA and BB non-empty, consider the number obtained by adding the product of elements of AA to the product of elements of BB. Let NN be the largest prime number among these numbers. Find the sum of the digits of NN.

Problem 24

The product 55×60×6555 \times 60 \times 65 is written as the product of five distinct positive integers. What is the least possible value of the largest of these integers?

Problem 25

A natural number nn is said to be good if nn is the sum of rr consecutive positive integers, for some r≥2r \geq 2. Find the number of good numbers in the set {1,2,…,100}\{1, 2, \ldots, 100\}.

Problem 26

Find the number of ordered pairs (a,b)(a, b) such that a,b∈{10,11,⋯ ,29,30}a, b \in \{10, 11, \cdots, 29, 30\} and GCD(a,b)+LCM(a,b)=a+b\mathrm{GCD}(a,b) + \mathrm{LCM}(a,b) = a + b.

Problem 27

Find the number of triples (a,b,c)(a, b, c) of positive integers such that

  1. abab is a prime;

  2. bcbc is a product of two primes;

  3. abcabc is not divisible by square of any prime and

  4. abc≤30abc \leq 30.

Problem 28

Let n=219312n = 2^{19}3^{12}. Let MM denote the number of positive divisors of n2n^2 which are less than nn but would not divide nn. What is the number formed by taking the last two digits of MM (in the same order)?

Problem 29

If 1−12+13+14+15+16+17=1x1+1x2+1x3+1x4+1x5+1x6+1x71 - \cfrac{1}{2 + \cfrac{1}{3 + \cfrac{1}{4 + \cfrac{1}{5 + \cfrac{1}{6 + \cfrac{1}{7}}}}}} = \cfrac{1}{x_1 + \cfrac{1}{x_2 + \cfrac{1}{x_3 + \cfrac{1}{x_4 + \cfrac{1}{x_5 + \cfrac{1}{x_6 + \cfrac{1}{x_7}}}}}}} where x1,x2,…,x7x_1, x_2, \ldots, x_7 are positive integers, find x1+x2+x3+x4+x5+x6+x7x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7.

Problem 30

Let ff be the function defined by f(n)=remainder when nn is divided by 7,f(n) = \text{remainder when } n^n \text{ is divided by } 7, for all positive integers nn. Find the smallest positive integer TT such that f(n+T)=f(n)f(n + T) = f(n) for all positive integers nn.

Problem 31

Let E={p4+p2−2∣p is a prime,p>3}E = \{p^4 + p^2 - 2 \mid p \text{ is a prime}, p > 3\}. What is the largest positive integer that divides all the numbers in EE?

Problem 32

For a natural number bb, let N(b)N(b) denote the number of natural numbers aa for which the equation x2+ax+b=0x^2 + ax + b = 0 has integer roots. What is the smallest value of bb for which N(b)=20N(b) = 20?

Problem 33

Let ff be a one-to-one function from the set of natural numbers to itself such that f(mn)=f(m)f(n)f(mn) = f(m)f(n) for all natural numbers mm and nn. What is the least possible value of f(999)f(999)?

Problem 34

Let p,qp, q be prime numbers such that n3pq−nn^{3pq} - n is a multiple of 3pq3pq for all positive integers nn. Find the least possible value of p+qp + q.

Problem 35

For each positive integer nn, consider the highest common factor hnh_n of the two numbers n!+1n! + 1 and (n+1)!(n+1)!. For n<100n < 100, find the largest value of hnh_n.

Problem 36

Let TT be the smallest positive integer which, when divided by 11,13,1511, 13, 15 leaves remainders in the sets {7,8,9}\{7, 8, 9\}, {1,2,3}\{1, 2, 3\}, {4,5,6}\{4, 5, 6\} respectively. What is the sum of the squares of the digits of TT?

Problem 37

A natural number k>1k > 1 is called good if there exist natural numbers a1<a2<⋯<aka_1 < a_2 < \cdots < a_k such that 1a1+1a2+…+1ak=1.\frac{1}{\sqrt{a_1}} + \frac{1}{\sqrt{a_2}} + \ldots + \frac{1}{\sqrt{a_k}} = 1. Let f(n)f(n) be the sum of the first nn good numbers, n≥1n \geq 1. Find the sum of all values of nn for which f(n+5)/f(n)f(n+5)/f(n) is an integer.

Problem 38

How many ordered pairs (a,b)(a, b) of positive integers with a<ba < b and 100≤a,b≤1000100 \leq a, b \leq 1000 satisfy gcd⁡(a,b):lcm⁡(a,b)=1:495\gcd(a, b) : \operatorname{lcm}(a, b) = 1 : 495?

Problem 39

Let EE denote the set of all natural numbers nn such that 3<n<1003 < n < 100 and the set {1,2,3,…,n}\{1, 2, 3, \ldots, n\} can be partitioned into 33 subsets with equal sums. Find the number of elements of EE.

Problem 40

For a positive integer nn, let ⟨n⟩\langle n \rangle denote the perfect square integer closest to nn. For example, ⟨74⟩=81\langle 74 \rangle = 81, ⟨18⟩=16\langle 18 \rangle = 16. If NN is the smallest positive integer such that ⟨91⟩⋅⟨120⟩⋅⟨143⟩⋅⟨180⟩⋅⟨N⟩=91⋅120⋅143⋅180⋅N\langle 91 \rangle \cdot \langle 120 \rangle \cdot \langle 143 \rangle \cdot \langle 180 \rangle \cdot \langle N \rangle = 91 \cdot 120 \cdot 143 \cdot 180 \cdot N find the sum of the squares of the digits of NN.

Problem 41

Find all natural numbers nn for which there exists a permutation σ\sigma of 1,2,…,n1, 2, \ldots, n such that ∑i=1nσ(i)(−2)i−1=0.\sum_{i=1}^{n} \sigma(i)(-2)^{i-1} = 0. Note: A permutation of 1,2,…,n1, 2, \ldots, n is a bijective function from {1,2,…,n}\{1, 2, \ldots, n\} to itself.

Problem 42

Suppose the prime numbers pp and qq satisfy q2+3p=197p2+qq^2 + 3p = 197p^2 + q. Write qp\dfrac{q}{p} as l+mnl + \dfrac{m}{n}, where l,m,nl, m, n are positive integers, m<nm < n and GCD(m,n)=1\mathrm{GCD}(m,n) = 1. Find the maximum value of l+m+nl + m + n.

Problem 43

For a positive integer n>1n > 1, let g(n)g(n) denote the largest positive proper divisor of nn and f(n)=n−g(n)f(n) = n - g(n). For example, g(10)=5g(10) = 5, f(10)=5f(10) = 5 and g(13)=1g(13) = 1, f(13)=12f(13) = 12. Let NN be the smallest positive integer such that f(f(f(N)))=97f(f(f(N))) = 97. Find the largest integer not exceeding N\sqrt{N}.

Problem 44

Let m,nm, n be natural numbers such that m+3n−5=2 LCM(m,n)−11 GCD(m,n).m + 3n - 5 = 2\,\mathrm{LCM}(m,n) - 11\,\mathrm{GCD}(m,n). Find the maximum possible value of m+nm + n.

Problem 45

A positive integer n>1n > 1 is called beautiful if nn can be written in one and only one way as n=a1+a2+⋯+ak=a1⋅a2⋯akn = a_1 + a_2 + \cdots + a_k = a_1 \cdot a_2 \cdots a_k for some positive integers a1,a2,…,aka_1, a_2, \ldots, a_k, where k>1k > 1 and a1≥a2≥⋯≥aka_1 \geq a_2 \geq \cdots \geq a_k. (For example 66 is beautiful since 6=3⋅2⋅1=3+2+16 = 3 \cdot 2 \cdot 1 = 3 + 2 + 1, and this is unique. But 88 is not beautiful since 8=4+2+1+1=4⋅2⋅1⋅18 = 4 + 2 + 1 + 1 = 4 \cdot 2 \cdot 1 \cdot 1 as well as 8=2+2+2+1+1=2⋅2⋅2⋅1⋅18 = 2 + 2 + 2 + 1 + 1 = 2 \cdot 2 \cdot 2 \cdot 1 \cdot 1, so uniqueness is lost.) Find the largest beautiful number less than 100.

Problem 46

Let d(m)d(m) denote the number of positive integer divisors of a positive integer mm. If rr is the number of integers n≤2023n \leq 2023 for which ∑i=1nd(i)\sum_{i=1}^{n} d(i) is odd, find the sum of the digits of rr.

Problem 47

Let p,qp, q be two-digit numbers neither of which are divisible by 1010. Let rr be the four-digit number by putting the digits of pp followed by the digits of qq (in order). As p,qp, q vary, a computer prints rr on the screen if gcd⁡(p,q)=1\gcd(p,q) = 1 and p+qp + q divides rr. Suppose that the largest number that is printed by the computer is NN. Determine the number formed by the last two digits of NN (in the same order).

Problem 48

Consider the fourteen numbers, 14,24,…,1441^4, 2^4, \ldots, 14^4. The smallest natural number nn such that they leave distinct remainders when divided by nn is:

Problem 49

Find the largest positive integer n<30n < 30 such that 12(n8+3n4−4)\dfrac{1}{2}(n^8 + 3n^4 - 4) is not divisible by the square of any prime number.

Problem 50

Find the number of ordered pairs (m,n)(m,n) where mm and nn are positive integers less than or equal to 20000 such that m2+n4m^2 + n^4 is a power of 2.

Problem 51

If a,b,c,da, b, c, d are positive integers such that 17(abcd+ab+ad+cd+1)=20(bcd+b+d),17(abcd + ab + ad + cd + 1) = 20(bcd + b + d), find a2+b2+c2+d2a^2 + b^2 + c^2 + d^2.

Problem 52

Find the number of ordered pairs (m,n)(m,n) where mm and nn are positive integers such that 1≤m<n≤501 \leq m < n \leq 50 and the product mnmn is a perfect square.

Problem 53

How many natural numbers n≤105n \leq 105 are there such that 7∣2n−n27 | 2^n - n^2?

Problem 54

Let n=431−13n = \dfrac{4^{31} - 1}{3}. Find the remainder when 2n−12^{n-1} is divided by nn.

Problem 55

Consider the set EE of all natural numbers nn such that when divided by 11,12,1311, 12, 13, respectively, the remainders, in that order, are distinct prime numbers in an arithmetic progression. If NN is the largest number in EE, find the sum of digits of NN.

Problem 56

Find the number of pairs (a,b)(a, b) of natural numbers such that bb is a 3-digit number, a+1a+1 divides b−1b-1 and bb divides a2+a+2a^2 + a + 2.

Problem 57

Find the number of ordered triples (a,b,c)(a, b, c) of positive integers such that 1≤a,b,c≤501 \leq a, b, c \leq 50 which satisfy the relation lcm(a,c)+lcm(b,c)a+b=26c27.\frac{\mathrm{lcm}(a, c) + \mathrm{lcm}(b, c)}{a + b} = \frac{26c}{27}. Here, by lcm(x,y)\mathrm{lcm}(x, y) we mean the LCM, that is, least common multiple of xx and yy.

Problem 58

Consider the collection MM of all ordered pairs (a,b)(a,b) of positive integers aa and bb which satisfy ab=406+11⋅lcm(a,b)+7⋅gcd⁡(a,b).ab = 406 + 11 \cdot \mathrm{lcm}(a,b) + 7 \cdot \gcd(a,b). What is the smallest possible value of a+ba + b?

Solutions

Solution: PRMO 2013, Q1

Key idea

The first check is whether the original sum is already a perfect power; here it is, so the multiplier needs no extra prime factors.

Add the three cubes: 27+64+125=216=63.27 + 64 + 125 = 216 = 6^3. So k=1k = 1 works, with a=6a = 6 and n=3n = 3, and no smaller positive integer exists.

The identity 33+43+53=633^3 + 4^3 + 5^3 = 6^3 is worth remembering. It is the smallest instance of four cubes in that relation, and it is what the question is really about: a reader who starts factorising 216216 into 23⋅332^3 \cdot 3^3 arrives at the same place a moment later.

Answer 1

Solution: PRMO 2014, Q1

Key idea

Locate the two consecutive squares on either side of 20142014; they determine kk, after which its prime factors answer the question.

The squares nearest 20142014 are 442=193644^2 = 1936 and 452=202545^2 = 2025, and 1936<2014<2025,1936 < 2014 < 2025, so k=44k = 44 and no other natural number will do, the squares being increasing.

Factorising, 44=22×1144 = 2^2 \times 11, so the largest prime factor is 1111.

Answer 11

Solution: IOQM 2024, Q1

Key idea

Every integer up to 1010 is built from the primes 22, 33, 55 and 77, all of which sit inside 9!9! with room to spare, and the first integer needing a new prime is 1111.

Write 9!=3628809! = 362880 in terms of its primes: 9!=27⋅34⋅5⋅7.9! = 2^7 \cdot 3^4 \cdot 5 \cdot 7. Any integer whose prime factorisation fits inside this one divides 9!9!, and the integers 11 through 1010 all do: for instance 8=238 = 2^3 and 9=329 = 3^2 and 10=2⋅510 = 2 \cdot 5 are covered comfortably. But 1111 is a prime that does not appear in the list at all, so it cannot divide 9!9!.

Hence the smallest positive integer that does not divide 9!9! is 1111.

Answer 11

Solution: IOQM 2025 Part SEP, Q7

Key idea

Count the multiples of 33 and remove those that are also multiples of 22, that is, the multiples of 66.

The multiples of 33 up to 100100 are 3,6,…,993, 6, \ldots, 99, and there are ⌊100/3⌋=33\lfloor 100/3 \rfloor = 33 of them. Among these, the ones divisible by 22 are exactly the multiples of 66, of which there are ⌊100/6⌋=16\lfloor 100/6 \rfloor = 16.

So the count is 33−16=1733 - 16 = 17.

Answer 17

Solution: IOQM 2025 Part SEP, Q28

Key idea

Such an nn is exactly a number of the form 2i3j2^i3^j, so list them by the power of 33.

A positive integer divisible by no prime other than 22 and 33 is precisely one of the form 2i3j2^i 3^j with i,j≥0i, j \ge 0, and n=1n = 1 counts, since it has no prime divisor at all. Listing them by the power of 33: 3jnumbers 2i3j≤100count11,2,4,8,16,32,64733,6,12,24,48,96699,18,36,7242727,54281811\begin{array}{r|l|c} 3^j & \text{numbers } 2^i3^j \le 100 & \text{count} \\ \hline 1 & 1, 2, 4, 8, 16, 32, 64 & 7 \\ 3 & 3, 6, 12, 24, 48, 96 & 6 \\ 9 & 9, 18, 36, 72 & 4 \\ 27 & 27, 54 & 2 \\ 81 & 81 & 1 \end{array} There are 7+6+4+2+1=207+6+4+2+1 = 20 of them.

Answer 20

Solution: IOQM 2026, Q2

Key idea

Since 256256 is itself a multiple of 44, taking away multiples of 256256 cannot spoil divisibility by 44, so the remainder is a multiple of 44, and it is not zero.

Write M=256q+rM = 256q + r with 0≤r≤2550 \le r \le 255. Then r=M−256qr = M - 256q is a difference of two multiples of 44, so rr is a multiple of 44. And r≠0r \ne 0, since r=0r = 0 would make MM a multiple of 256256.

So rr is one of 4,8,12,…,2524, 8, 12, \ldots, 252, and every one of these really occurs, because M=rM = r is divisible by 44 and not by 256256. The list runs from 4⋅14 \cdot 1 to 4⋅634 \cdot 63, so there are 6363 possible remainders.

Answer 63

Solution: PRMO 2015 Part A, Q4

Key idea

For integer polynomials n−0n - 0 always divides P(n)−P(0)P(n) - P(0), so the hypothesis forces every nn to divide the single fixed number P(0)P(0).

For example, take P(x)=x2+5P(x)=x^2+5: P(3)−P(1)=14−6=8P(3)-P(1)=14-6=8 is divisible by 3−1=23-1=2. The constant cancels, and the same factorisation principle works term by term for any integer polynomial.

The tool here is a fact about polynomials with integer coefficients: for any integers uu and vv, the difference u−vu - v divides P(u)−P(v)P(u) - P(v). It follows from uk−vk=(u−v)(uk−1+uk−2v+⋯+vk−1)u^k - v^k = (u - v)(u^{k-1} + u^{k-2}v + \cdots + v^{k-1}) applied term by term, and the coefficients being integers is exactly what makes the resulting factorisation an integer one.

Take v=0v = 0. Then nn divides P(n)−P(0)P(n) - P(0) for every positive integer nn. We are told that nn also divides P(n)P(n), so subtracting, n∣P(0)for every positive integer n.n \mid P(0) \qquad \text{for every positive integer } n. Now P(0)P(0) is one fixed integer, and no non-zero integer is divisible by every positive integer, since nn larger than ∣P(0)∣|P(0)| would already be too big. Therefore P(0)=0P(0) = 0.

Note that the condition "PP is non-zero" is there to keep the polynomial itself interesting, not to rescue the argument: P(x)=xP(x) = x is a perfectly good example, and its value at 00 is indeed 00.

Answer 0

Solution: PRMO 2019, Q4

Key idea

Equal legs and equal turns put every stop on one circle, each leg cutting off the same arc, so the ant is home when a whole number of legs makes a whole number of laps.

image

At each stop the ant turns 160∘160^{\circ} to the right, so the angle between the leg it arrives on and the leg it leaves on, measured inside the path, is 180∘−160∘=20∘180^{\circ} - 160^{\circ} = 20^{\circ}.

Every stop lies on one circle

Call the anthill A0A_0 and the stops A1,A2,…A_1, A_2, \ldots in the order the ant reaches them. Draw the circle through A0A_0, A1A_1 and A2A_2, and let OO be its centre. Equal chords of a circle subtend equal angles at the centre, and A0A1=A1A2=4A_0A_1 = A_1A_2 = 4, so the rotation about OO that carries A0A_0 to A1A_1 also carries A1A_1 to A2A_2. That is, it carries the first leg of the walk to the second.

The same rotation carries the second leg to the third, because the third leg stands to the second exactly as the second stands to the first: the same length, turned right through the same 160∘160^{\circ}. Repeating the argument, one fixed rotation about OO carries every leg to the next. So every stop lies on that one circle, and consecutive stops are the same distance apart round it.

How far round the circle one leg goes

The angle ∠A0A1A2=20∘\angle A_0A_1A_2 = 20^{\circ} stands at the circumference on the arc A0A2A_0A_2 that does not contain A1A_1, so that arc measures 40∘40^{\circ}. The rest of the circle, which is 360∘−40∘=320∘360^{\circ} - 40^{\circ} = 320^{\circ}, is the arc from A0A_0 to A2A_2 the other way round, through A1A_1, and it is made of two equal steps. Each leg therefore advances the ant 160∘160^{\circ} round the circle.

When the ant gets home

After nn legs the ant has gone 160n160n degrees round the circle, and it is back at the anthill exactly when that is a whole number of complete laps: 360∣160n,which after dividing by 40 reads9∣4n.360 \mid 160n, \qquad\text{which after dividing by } 40 \text{ reads}\qquad 9 \mid 4n. Since 44 and 99 share no factor, 99 must divide nn, so the first return is at n=9n = 9 and the ant walks 9×4=369 \times 4 = 36 feet. Nine steps of 160∘160^{\circ} come to 1440∘1440^{\circ}, which is four laps, so the ant circles the anthill four times before closing up. The nine stops are equally spaced round the circle, 40∘40^{\circ} apart, and the ant visits every fourth one: that is the nine-pointed star in the figure.

Answer 36

Solution: PRMO 2019, Q14

Key idea

A square is 77 modulo 99 only for m≡±4(mod9)m \equiv \pm4 \pmod 9, which thins the candidates to a short list, and then the primality of n+6n+6 picks the third of them.

Write 9n+7=m29n + 7 = m^2 with mm a positive integer. Reducing modulo 99, m2≡7(mod9).m^2 \equiv 7 \pmod 9. The squares modulo 99 are 0,1,4,70, 1, 4, 7, and m2≡7m^2 \equiv 7 happens exactly for

m≡4m \equiv 4 or m≡5(mod9)m \equiv 5 \pmod 9, since 42=16≡74^2 = 16 \equiv 7 and 52=25≡75^2 = 25 \equiv 7 while the other remainders give 0,10, 1 or 44.

So m∈{4,5,13,14,22,23,…}m \in \{4, 5, 13, 14, 22, 23, \ldots\}, and n=(m2−7)/9n = (m^2 - 7)/9 grows with mm. Running through them in order and keeping only n≥10n \ge 10: m=13: n=18,m=14: n=21,m=22: n=53,m = 13:\ n = 18, \qquad m = 14:\ n = 21, \qquad m = 22:\ n = 53, the values m=4,5m = 4, 5 giving n=1,2n = 1, 2, which are too small.

Now test the primality of n+6n + 6 in that order. For n=18n = 18 we get 24=23⋅324 = 2^3 \cdot 3, not prime. For n=21n = 21 we get 27=3327 = 3^3, not prime. For n=53n = 53 we get 5959, which is prime, since it is divisible by none of 22, 33, 55, 77 and 72=49<59<647^2 = 49 < 59 < 64. Also 9×53+7=484=2229 \times 53 + 7 = 484 = 22^2, as required.

The smallest such nn is 5353.

Answer 53

Solution: IOQM 2020, Q6

Key idea

A whole number is a perfect square exactly when every exponent in its prime factorisation is even, so the problem reduces to factorising and repairing the odd exponents.

The expression is disguised by its composite bases, and the first move is to rewrite everything in terms of the primes 22, 33 and 55. Since 4=224 = 2^2 and 6=2⋅36 = 2 \cdot 3, 25⋅36⋅43⋅53⋅67=25⋅36⋅26⋅53⋅27⋅37=218⋅313⋅53.2^5 \cdot 3^6 \cdot 4^3 \cdot 5^3 \cdot 6^7 = 2^5 \cdot 3^6 \cdot 2^6 \cdot 5^3 \cdot 2^7 \cdot 3^7 = 2^{18} \cdot 3^{13} \cdot 5^{3}.

Now the criterion does all the work. A number is a perfect square precisely when each prime occurs to an even power, because a square is a product of two identical factorisations. Here the exponent of 22 is already even and needs nothing, while the exponents of 33 and of 55 are both odd and each needs one more copy of its prime.

Multiplying by 3⋅5=153 \cdot 5 = 15 therefore does the job, giving 218⋅314⋅542^{18} \cdot 3^{14} \cdot 5^4. Nothing smaller can work, because any successful multiplier must supply at least one factor of 33 and at least one factor of 55, and the smallest positive integer doing both is 1515.

Answer 15

Solution: IOQM 2020, Q17

Key idea

Having exactly four divisors is a statement about shape, not size: it happens only for p3p^3 and for pqpq with pp and qq distinct primes.

For a small example, 12=22⋅312=2^2\cdot3 has divisors 1,2,3,4,6,121,2,3,4,6,12. We choose the exponent of 22 in three ways and the exponent of 33 in two ways, giving 3⋅2=63\cdot2=6 divisors. This is the pattern behind the divisor-count formula.

The number of divisors of n=p1e1p2e2⋯n = p_1^{e_1} p_2^{e_2} \cdots is (e1+1)(e2+1)⋯(e_1+1)(e_2+1)\cdots, since a divisor is built by choosing an exponent for each prime independently. For that product to equal 44 there are only two ways to break 44 into factors bigger than one, namely 44 itself and 2×22 \times 2. The first gives a single prime with exponent 33, so n=p3n = p^3; the second gives two distinct primes each with exponent 11, so n=pqn = pq. Every two-digit number with exactly four divisors is therefore of one of these two shapes, and we count each.

The cubes are quickly exhausted. Since 23=82^3 = 8 has only one digit and 53=1255^3 = 125 has three, the only two-digit cube of a prime is 33=273^3 = 27.

For the products of two distinct primes, fix the smaller prime and list the larger one: ppossible q>p with 10≤pq≤99count25,7,11,13,17,19,23,29,31,37,41,43,471335,7,11,13,17,19,23,29,31957,11,13,17,195711,132\begin{array}{c|l|c} p&\text{possible }q>p\text{ with }10\le pq\le99&\text{count}\\\hline 2&5,7,11,13,17,19,23,29,31,37,41,43,47&13\\ 3&5,7,11,13,17,19,23,29,31&9\\ 5&7,11,13,17,19&5\\ 7&11,13&2 \end{array} There is no row with smaller prime 1111 or above, since 11⋅13=14311\cdot13=143 already exceeds two digits. Adding up, the products contribute 13+9+5+2=2913 + 9 + 5 + 2 = 29, and the single cube contributes one more, for a total of 3030.

Answer 30

Solution: IOQM 2021 Part A, Q3

Key idea

Three distinct primes in arithmetic progression that also form a triangle: the smallest such triple is 3,5,73, 5, 7, and its largest angle is a familiar 120∘120^{\circ}.

image

We want three distinct primes in arithmetic progression which can be the sides of a genuine triangle, and among all such triples we want the one of least perimeter, so start small and work up. The smallest candidates are 3,5,73, 5, 7, whose common difference is 22, and they do form a triangle since 3+5>73 + 5 > 7. Nothing smaller is available. These are the three smallest odd primes, so no triple of odd primes has a smaller sum, and a progression using 22 must have 22 as its smallest term, since no prime is smaller, so its terms are 22, 2+d2+d, 2+2d2+2d, and the largest of those is even and exceeds 22, so it is not prime. The least perimeter is therefore L=3+5+7=15L = 3 + 5 + 7 = 15.

The largest angle lies opposite the longest side, 77. By the cosine rule, cos⁡θ=32+52−722⋅3⋅5=9+25−4930=−1530=−12,\cos\theta = \frac{3^2 + 5^2 - 7^2}{2 \cdot 3 \cdot 5} = \frac{9 + 25 - 49}{30} = \frac{-15}{30} = -\frac12, so θ=120∘\theta = 120^{\circ} and a=120a = 120. The clean value of the cosine is a sign that this triple was chosen deliberately.

Therefore aL=12015=8\dfrac{a}{L} = \dfrac{120}{15} = 8.

Answer 8

Solution: IOQM 2023, Q6

Key idea

The interior angle of a regular kk-gon is 180∘−360∘/k180^{\circ} - 360^{\circ}/k, so asking for an even integer angle is asking for an even divisor of 360360 that leaves at least three sides.

image

A regular polygon with k≥3k \ge 3 sides has interior angle n=180−360k.n = 180 - \frac{360}{k}. Write d=360/kd = 360/k. For nn to be an integer, dd must be an integer, that is kk must divide 360360, and then dd is itself a divisor of 360360; and since 180180 is even, nn is even exactly when dd is even. The constraint k≥3k \ge 3 becomes d=360/k≤120d = 360/k \le 120, and n>0n > 0 is then automatic.

So the task is to count the even divisors of 360360 that are at most 120120. Since 360=23⋅32⋅5360 = 2^3 \cdot 3^2 \cdot 5 has 4⋅3⋅2=244 \cdot 3 \cdot 2 = 24 divisors, of which the odd ones are the 3⋅2=63 \cdot 2 = 6 divisors of 4545, there are 24−6=1824 - 6 = 18 even divisors. Exactly two of them exceed 120120, namely 180180 and 360360. That leaves 18−2=1618 - 2 = 16 admissible values of dd, and distinct values of dd give distinct angles n=180−dn = 180 - d.

A remark on the wording, since it worries people. If "the angle of a regular polygon" were read as the exterior angle 360/k360/k instead, the count would be of even divisors of 360360 that are at most 120120 once more, and the answer would be the same 1616. The ambiguity is harmless.

Answer 16

Solution: IOQM 2025 Part SEP, Q28

Key idea

The four largest primes below 7070 happen to sum to exactly 240240, so there is no freedom at all.

A sum as large as 240240 from four numbers none above 7070 needs every one of them near the top, so look at the largest primes not exceeding 7070: they are 67,61,59,53,47,…67, 61, 59, 53, 47, \ldots, and 67+61+59+53=24067 + 61 + 59 + 53 = 240 exactly. Any other choice of four distinct primes below 7070 replaces one of these by a smaller prime and gives a total below 240240.

So the four primes are forced, and the smallest is 5353.

Answer 53

Solution: IOQM 2025 Part SEP, Q28

Key idea

The set of required divisors changes only at the cubes 88, 2727 and 6464, so split the range at those points and count multiples of 11, 22, 66 and 1212.

The condition involves every ii with i3≤ni^3 \le n, and that set of ii grows only when nn passes a cube. rangedivisors imultiple ofcount1≤n≤71178≤n≤261,221027≤n≤631,2,36664≤n≤1001,2,3,4123\begin{array}{c|c|c|c} \text{range} & \text{divisors } i & \text{multiple of} & \text{count} \\ \hline 1 \le n \le 7 & 1 & 1 & 7 \\ 8 \le n \le 26 & 1, 2 & 2 & 10 \\ 27 \le n \le 63 & 1,2,3 & 6 & 6 \\ 64 \le n \le 100 & 1,2,3,4 & 12 & 3 \end{array} The counts in the last column are the multiples in each range: 8,10,…,268, 10, \ldots, 26 gives ten numbers; 30,36,…,6030, 36, \ldots, 60 gives six; and 72,84,9672, 84, 96 gives three.

The total is 7+10+6+3=267 + 10 + 6 + 3 = 26.

Answer 26

Solution: PRMO 2012, Q11

Key idea

Five consecutive odd factors always include a multiple of 33 and one of 55. Comparing several sample products then shows whether any further factor is forced.

At n=2n=2 the factors are 3,5,7,9,113,5,7,9,11. They visibly supply both 33 and 55, but we must ask which of those factors remain compulsory as the run moves. That question is about the remainders of consecutive odd numbers.

For even nn the five factors n+1,n+3,n+5,n+7,n+9n+1, n+3, n+5, n+7, n+9 are five consecutive odd numbers.

Among any three consecutive odd numbers the remainders modulo 33 run through all three possibilities, so one of them is a multiple of 33. Among any five consecutive odd numbers the remainders modulo 55 likewise run through all five, so one is a multiple of 55. Hence 1515 divides P(n)P(n) always.

Any integer dividing every product must divide the HCF of any samples we choose. We use products that leave different small primes out, so their common factors can be tested. Take n=10n = 10 and n=12n = 12: P(10)=11⋅13⋅15⋅17⋅19,P(12)=13⋅15⋅17⋅19⋅21.P(10) = 11 \cdot 13 \cdot 15 \cdot 17 \cdot 19, \qquad P(12) = 13 \cdot 15 \cdot 17 \cdot 19 \cdot 21. The first is 3⋅5⋅11⋅13⋅17⋅193 \cdot 5 \cdot 11 \cdot 13 \cdot 17 \cdot 19 and the second is 32⋅5⋅7⋅13⋅17⋅193^2 \cdot 5 \cdot 7 \cdot 13 \cdot 17 \cdot 19, whose greatest common divisor is 3⋅5⋅13⋅17⋅193 \cdot 5 \cdot 13 \cdot 17 \cdot 19. Bringing in P(2)=3⋅5⋅7⋅9⋅11P(2) = 3 \cdot 5 \cdot 7 \cdot 9 \cdot 11 kills the 1313, 1717 and 1919, leaving 1515.

So the answer is 15.15.

Answer 15

Solution: PRMO 2012, Q16

Key idea

The rule f(mn)=f(m)f(n)f(mn) = f(m)f(n) fixes ff on the powers of two, and the fact that ff increases squeezes every value in between, so f(n)=nf(n) = n throughout.

First f(1)=f(1⋅1)=f(1)2f(1) = f(1 \cdot 1) = f(1)^2, and the only natural number equal to its own square is 11, since the natural numbers here start at 11. So f(1)=1f(1) = 1, and f(2)=2f(2) = 2 gives f(4)=4f(4) = 4, f(8)=8f(8) = 8, f(16)=16f(16) = 16, and in general f(2k)=2kf(2^k) = 2^k.

Now squeeze. Between f(2)=2f(2) = 2 and f(4)=4f(4) = 4 there is room for exactly one value, and ff is strictly increasing, so f(3)=3f(3) = 3. Between f(4)=4f(4) = 4 and f(8)=8f(8) = 8 there are three integers and three values f(5)<f(6)<f(7)f(5) < f(6) < f(7) to place, so f(5)=5f(5) = 5, f(6)=6f(6) = 6, f(7)=7f(7) = 7. The same argument between 88 and 1616, where seven values must fill seven places, gives f(n)=nf(n) = n for n=9,…,15n = 9, \ldots, 15, and once more between 1616 and 3232 for nn up to 2020.

So ff is the identity on the range we need, and ∑k=120f(k)=∑k=120k=20×212=210.\sum_{k=1}^{20} f(k) = \sum_{k=1}^{20} k = \frac{20 \times 21}{2} = 210.

The three conditions are exactly enough: drop the increasing condition and any rearrangement of the odd primes would do, drop f(2)=2f(2) = 2 and f(n)=n2f(n) = n^2 would do.

Answer 210

Solution: PRMO 2013, Q18

Key idea

kk consecutive integers from aa sum to k2(2a+k−1)\tfrac k2(2a + k - 1), so k(2a+k−1)=4026k(2a+k-1) = 4026 and kk is a divisor of 40264026 small enough to leave a≥1a \ge 1.

Writing the run as a,a+1,…,a+k−1a, a+1, \ldots, a+k-1 with a≥1a \ge 1, ka+k(k−1)2=2013,that isk(2a+k−1)=4026.ka + \frac{k(k-1)}{2} = 2013, \qquad \text{that is} \qquad k\left(2a + k - 1\right) = 4026. So kk divides 4026=2×3×11×614026 = 2 \times 3 \times 11 \times 61.

The requirement a≥1a \ge 1 caps kk: 2a=4026k−k+1≥2  ⟹  k(k+1)≤4026  ⟹  k≤62.2a = \frac{4026}{k} - k + 1 \ge 2 \implies k(k+1) \le 4026 \implies k \le 62.

The divisors of 40264026 at most 6262 are 1,2,3,6,11,22,33,611, 2, 3, 6, 11, 22, 33, 61, and the largest is 6161. It works: 402661=66\tfrac{4026}{61} = 66, so 2a=66−61+1=62a = 66 - 61 + 1 = 6 and a=3a = 3. Indeed 3+4+⋯+63=(3+63)×612=2013.3 + 4 + \cdots + 63 = \frac{(3 + 63) \times 61}{2} = 2013.

So the maximum is k=61k = 61.

Answer 61

Solution: PRMO 2014, Q11

Key idea

Writing x=dax = da and y=dby = db with gcd⁡(a,b)=1\gcd(a,b) = 1 turns the equation into dab=a+b+1dab = a + b + 1, and ab≤a+b+1ab \le a + b + 1 leaves almost nothing.

Put d=gcd⁡(x,y)d = \gcd(x,y) and x=dax = da, y=dby = db with gcd⁡(a,b)=1\gcd(a,b) = 1 and a≤ba \le b. The equation xy=x+y+gcd⁡(x,y)xy = x + y + \gcd(x,y) becomes d2ab=d(a+b)+d,sod ab=a+b+1.d^2ab = d(a + b) + d, \qquad \text{so} \qquad d\,ab = a + b + 1.

In particular abab divides a+b+1a + b + 1, so ab≤a+b+1ab \le a + b + 1, that is (a−1)(b−1)≤2.(a-1)(b-1) \le 2. With a≤ba \le b and gcd⁡(a,b)=1\gcd(a,b) = 1 that leaves a=1a = 1 with any bb, or (a,b)=(2,3)(a,b) = (2,3).

  • a=1a = 1: the condition is b∣b+2b \mid b + 2, so b∣2b \mid 2 and b∈{1,2}b \in \{1, 2\}. For b=1b = 1, d=3d = 3 gives (x,y)=(3,3)(x,y) = (3,3); for b=2b = 2, d=42=2d = \tfrac42 = 2 gives (x,y)=(2,4)(x,y) = (2,4).

  • (a,b)=(2,3)(a,b) = (2,3): then 6d=66d = 6, so d=1d = 1 and (x,y)=(2,3)(x,y) = (2,3).

All three check out: 9=3+3+39 = 3+3+3, 8=2+4+28 = 2+4+2 and 6=2+3+16 = 2+3+1. So there are 33 pairs.

Answer 3

Solution: PRMO 2014, Q13

Key idea

Substituting d=9999−nd = 9999 - n turns the fraction into 8×9999d−8\tfrac{8 \times 9999}{d} - 8, so dd must be a divisor of 7999279992 lying in a narrow window.

Put d=9999−nd = 9999 - n, so that n=9999−dn = 9999 - d and 8n9999−n=8(9999−d)d=79992d−8.\frac{8n}{9999-n} = \frac{8(9999 - d)}{d} = \frac{79992}{d} - 8. The expression is an integer exactly when dd divides 79992=23×32×11×10179992 = 2^3 \times 3^2 \times 11 \times 101.

Now use the range. As nn runs from 11 to 20142014, the number dd runs from 99989998 down to 79857985. Writing 79992=qd79992 = qd, the bounds on dd become bounds on qq: q=79992d∈[799929998, 799927985]=[8.001…, 10.01…],q = \frac{79992}{d} \in \left[\frac{79992}{9998},\ \frac{79992}{7985}\right] = [8.001\ldots,\ 10.01\ldots], so qq is 99 or 1010. Of these only 99 divides 7999279992, since 7999279992 is not a multiple of 55. That gives d=799929=8888,n=9999−8888=1111,d = \frac{79992}{9} = 8888, \qquad n = 9999 - 8888 = 1111, and indeed 8×11118888=1\tfrac{8 \times 1111}{8888} = 1.

So exactly 11 value of nn works.

Answer 1

Solution: PRMO 2015 Part A, Q13

Key idea

The digits xx and yy must themselves be primes, so only four choices remain for each. List the pairs for which 10x+y10x+y is prime, then compare their products.

We need n=x⋅y⋅(10x+y)n = x \cdot y \cdot (10x+y) with xx, yy and 10x+y10x + y three distinct primes, and xx, yy single digits. A single-digit prime is one of 2,3,5,72, 3, 5, 7, which cuts the search down to sixteen pairs before any thought at all.

So run through the four values of xx, and for each list which of the four numbers 10x+y10x + y is prime. With x=7x = 7, for instance, the candidates are 7272, 7373, 7575 and 7777, and only 7373 is prime. Every value of xx turns out to leave exactly one choice of yy: x10x+y primeyn=x⋅y⋅(10x+y)22331383377777553379577331533\begin{array}{c|c|c|c} x & 10x + y \text{ prime} & y & n = x \cdot y \cdot (10x+y) \\ \hline 2 & 23 & 3 & 138 \\ 3 & 37 & 7 & 777 \\ 5 & 53 & 3 & 795 \\ 7 & 73 & 3 & 1533 \end{array} In each row the three primes are distinct, as required.

The largest is n=1533n = 1533, and the sum of its digits is 1+5+3+3=121 + 5 + 3 + 3 = 12.

Answer 12

Solution: PRMO 2018, Q22

Key idea

Each subset sums to kk, so kk divides the total 210210; and the part holding 2020 forces k≥20k \ge 20, while “proper” rules out k=210k = 210. Six divisors survive, and each is achievable.

The whole set sums to 1+2+⋯+20=2101 + 2 + \cdots + 20 = 210. If the parts each sum to kk then kk divides 210210.

Two more constraints trim the list. The part containing 2020 has sum at least 2020, so k≥20k \ge 20. And the subsets must be proper, so there is more than one of them, which rules out k=210k = 210.

The divisors of 210=2⋅3⋅5⋅7210 = 2 \cdot 3 \cdot 5 \cdot 7 lying in [20,210)[20, 210) are 21,30,35,42,70,105,21, \quad 30, \quad 35, \quad 42, \quad 70, \quad 105, six of them. Each is genuinely achievable, and here is a splitting for each:

  • k=21k = 21: the ten pairs {1,20},{2,19},…,{10,11}\{1,20\}, \{2,19\}, \ldots, \{10,11\}.

  • k=30k = 30: {20,10}\{20,10\}, {19,11}\{19,11\}, {18,12}\{18,12\}, {17,13}\{17,13\}, {16,14}\{16,14\}, {15,9,6}\{15,9,6\}, {1,2,3,4,5,7,8}\{1,2,3,4,5,7,8\}.

  • k=35k = 35: {20,15}\{20,15\}, {19,16}\{19,16\}, {18,17}\{18,17\}, {14,13,8}\{14,13,8\}, {12,11,10,2}\{12,11,10,2\}, {1,3,4,5,6,7,9}\{1,3,4,5,6,7,9\}.

  • k=42k = 42: {20,19,3}\{20,19,3\}, {18,17,7}\{18,17,7\}, {16,15,11}\{16,15,11\}, {14,13,12,2,1}\{14,13,12,2,1\}, {10,9,8,6,5,4}\{10,9,8,6,5,4\}.

  • k=70k = 70: {20,19,18,13}\{20,19,18,13\}, {17,16,15,14,8}\{17,16,15,14,8\}, and everything else.

  • k=105k = 105: {20,19,18,17,16,15}\{20,19,18,17,16,15\} and {1,2,…,14}\{1,2,\ldots,14\}.

So there are 66 good numbers.

Answer 6

Solution: PRMO 2019, Q21

Key idea

The sum is odd only when one of the two products is odd, so one part must sit inside {5,7,9}\{5,7,9\} and the other must swallow both 66 and 88, which leaves seven cases instead of fifteen.

A prime larger than 22 is odd, and the two products here are both at least 55, so their sum must be odd. A product is odd exactly when every factor is odd, so exactly one of the two parts consists of odd numbers only, that is one part is a non-empty subset of {5,7,9}\{5, 7, 9\} and the other contains both 66 and 88.

That leaves seven splittings, and each is one multiplication:

A={5}:5+6⋅7⋅8⋅9=3029=13×233A={7}:7+5⋅6⋅8⋅9=2167=11×197A={9}:9+5⋅6⋅7⋅8=1689=3×563A={5,7}:35+6⋅8⋅9=467primeA={5,9}:45+6⋅7⋅8=381=3×127A={7,9}:63+5⋅6⋅8=303=3×101A={5,7,9}:315+6⋅8=363=3×121\begin{array}{lrl} A = \{5\}: & 5 + 6\cdot7\cdot8\cdot9 = 3029 & = 13 \times 233 \\ A = \{7\}: & 7 + 5\cdot6\cdot8\cdot9 = 2167 & = 11 \times 197 \\ A = \{9\}: & 9 + 5\cdot6\cdot7\cdot8 = 1689 & = 3 \times 563 \\ A = \{5,7\}: & 35 + 6\cdot8\cdot9 = 467 & \text{prime} \\ A = \{5,9\}: & 45 + 6\cdot7\cdot8 = 381 & = 3 \times 127 \\ A = \{7,9\}: & 63 + 5\cdot6\cdot8 = 303 & = 3 \times 101 \\ A = \{5,7,9\}: & 315 + 6\cdot8 = 363 & = 3 \times 121 \end{array}

Four of the composites are caught by the digit-sum test for 33, and the two larger ones need a moment: 3029=13×2333029 = 13 \times 233 and 2167=11×1972167 = 11 \times 197. As for 467467, it is prime because it is divisible by none of 2,3,5,7,11,13,17,192, 3, 5, 7, 11, 13, 17, 19, and 222=48422^2 = 484 already exceeds it.

So the only prime among these numbers is N=467N = 467, which is therefore also the largest, and its digits sum to 4+6+7=174 + 6 + 7 = 17.

Answer 17

Solution: IOQM 2020, Q14

Key idea

The two large primes in the factorisation pin down two of the five integers immediately, and what is left over cannot be shared out among three distinct integers below twenty.

Begin by factorising the product completely, since a question about writing a number as a product of integers is really a question about how its primes may be distributed: 55×60×65=(5⋅11)(22⋅3⋅5)(5⋅13)=22⋅3⋅53⋅11⋅13.55 \times 60 \times 65 = (5 \cdot 11)(2^2 \cdot 3 \cdot 5)(5 \cdot 13) = 2^2 \cdot 3 \cdot 5^3 \cdot 11 \cdot 13.

Now suppose, aiming for a contradiction, that all five integers could be kept at 1919 or below. The prime 1111 has to divide one of them, and the only multiple of 1111 that does not exceed 1919 is 1111 itself, so one of the five is exactly 1111; the same reasoning with 1313 pins down a second. Dividing them out leaves three distinct integers whose product is 21450011⋅13=1500=22⋅3⋅53.\frac{214500}{11 \cdot 13} = 1500 = 2^2 \cdot 3 \cdot 5^3.

Those three must carry 535^3 between them, and none of them can be divisible by 2525, since 2525 already exceeds 1919. Each of the three is therefore divisible by 55 exactly once, which forces all three to be drawn from 55, 1010 and 1515, the only multiples of 55 below 2020 that are not multiples of 2525. Their product is 750750, not 15001500, and the contradiction is complete.

So the largest integer must be at least 2020, and 2020 is attainable: 5×11×13×15×20=214500,5 \times 11 \times 13 \times 15 \times 20 = 214500, with all five factors distinct. The least possible value of the largest is 2020.

Answer 20

Solution: IOQM 2020, Q28

Key idea

A number fails to be a sum of two or more consecutive positive integers exactly when it is a power of two, so counting the failures is far quicker than counting the successes.

A few small cases show the pattern before any algebra. We have 3=1+23 = 1 + 2, 5=2+35 = 2 + 3, 6=1+2+36 = 1 + 2 + 3, 9=4+59 = 4 + 5, 10=1+2+3+410 = 1 + 2 + 3 + 4 and 12=3+4+512 = 3 + 4 + 5, but 11, 22, 44 and 88 resist every attempt. The numbers that resist are the powers of two, and the algebra explains why.

Suppose nn is the sum of rr consecutive positive integers starting at mm, with r≥2r \geq 2. Summing the progression, n=m+(m+1)+⋯+(m+r−1)=r(2m+r−1)2,n = m + (m+1) + \cdots + (m+r-1) = \frac{r\left(2m + r - 1\right)}{2}, so that 2n=r(2m+r−1)2n = r\left(2m + r - 1\right). Read that as it stands: a run of consecutive integers is the number of terms times twice their average, and the useful part is that one of those two factors has to be odd, whatever nn is.

Look at the two factors on the right. Their sum is 2m+2r−12m + 2r - 1, which is odd, so exactly one of rr and 2m+r−12m+r-1 is even and the other is odd. Since r≥2r \geq 2 and m≥1m \geq 1, both factors are at least 22. So 2n2n has been written as a product of an even number and an odd number greater than one, which means nn itself has an odd divisor greater than 11.

Conversely, suppose nn is not a power of two, and write n=2sq,q>1 odd.n = 2^s q, \qquad q > 1 \text{ odd}. Since qq is odd and 2s+12^{s+1} is even the two are never equal, so exactly one of the following two constructions applies.

If q<2s+1q < 2^{s+1}, take the qq consecutive integers centred at 2s2^s, namely 2s−q−12,…,2s+q−12.2^s - \frac{q-1}{2}, \quad \ldots, \quad 2^s + \frac{q-1}{2}. There are qq of them and their average is 2s2^s, so they sum to 2sq=n2^s q = n. They are positive because qq is odd and less than 2s+12^{s+1}, so q≤2s+1−1q \leq 2^{s+1} - 1 and the first term is at least 11. And q≥3q \geq 3, so there are at least two terms.

If q>2s+1q > 2^{s+1}, take instead the 2s+12^{s+1} consecutive integers starting at m=q−2s+1+12,m = \frac{q - 2^{s+1} + 1}{2}, which is a whole number because qq is odd, and is positive because q≥2s+1+1q \geq 2^{s+1} + 1. Their sum is 2s+1m+(0+1+⋯+(2s+1−1))=2s(q−2s+1+1)+2s(2s+1−1),2^{s+1} m + \bigl(0 + 1 + \cdots + (2^{s+1} - 1)\bigr) = 2^s\bigl(q - 2^{s+1} + 1\bigr) + 2^s\bigl(2^{s+1} - 1\bigr), and the two brackets add to qq, leaving 2sq=n2^s q = n.

So the numbers that are not good are exactly those with no odd divisor beyond 11, which is to say the powers of two.

In the range from 11 to 100100 the powers of two are 1,2,4,8,16,32,641, 2, 4, 8, 16, 32, 64, seven numbers in all. Every other number in the range is good, so the count is 100−7=93100 - 7 = 93.

Answer 93

Solution: IOQM 2022, Q7

Key idea

Strip out the common factor. The condition collapses to (x−1)(y−1)=0(x-1)(y-1) = 0, which says that one of the two numbers divides the other.

Write g=gcd⁡(a,b)g = \gcd(a,b) and a=gxa = gx, b=gyb = gy with gcd⁡(x,y)=1\gcd(x,y) = 1, so that LCM(a,b)=gxy\mathrm{LCM}(a,b) = gxy. The condition becomes g+gxy=gx+gy.g + gxy = gx + gy. Dividing by gg and rearranging, xy−x−y+1=0xy - x - y + 1 = 0, that is (x−1)(y−1)=0.(x-1)(y-1) = 0.

So x=1x = 1 or y=1y = 1, which means a∣ba \mid b or b∣ab \mid a. The whole gcd-and-lcm dressing was hiding a divisibility condition.

Now count ordered pairs from {10,11,…,30}\{10, 11, \ldots, 30\}. The pairs with a=ba = b number 2121, one for each value. For the strictly ordered ones, list the pairs a<ba < b with a∣ba \mid b: since b≤30b \leq 30 and a≥10a \geq 10, the quotient can only be 22 or 33, giving (10,20), (10,30), (11,22), (12,24), (13,26), (14,28), (15,30),(10,20),\ (10,30),\ (11,22),\ (12,24),\ (13,26),\ (14,28),\ (15,30), which is 77 pairs, and each contributes two ordered pairs.

The total is 21+2⋅7=3521 + 2 \cdot 7 = 35.

Answer 35

Solution: IOQM 2023, Q9

Key idea

Condition (a) forces one of aa and bb to be 11, and the two resulting cases are short enough to finish by listing primes with product at most 3030.

A prime has exactly two positive divisors, so if abab is prime then one of a,ba, b equals 11 and the other is that prime. Condition (c) says abcabc is squarefree, so all the primes appearing below are distinct. Take the two cases in turn.

Case b=1b = 1, a=pa = p prime. Then bc=cbc = c, and condition (b) says cc is a product of two primes, say c=qrc = qr. Squarefreeness makes pp, qq, rr three distinct primes, and (d) requires pqr≤30pqr \le 30. The smallest product of three distinct primes is 2⋅3⋅5=302 \cdot 3 \cdot 5 = 30, so that is the only possibility, and the three triples are obtained by choosing which prime plays the role of aa: (2,1,15),(3,1,10),(5,1,6).(2, 1, 15), \quad (3, 1, 10), \quad (5, 1, 6). That is 33 triples.

Case a=1a = 1, b=pb = p prime. Then bc=pcbc = pc must be a product of two primes, which forces cc to be a prime qq, distinct from pp by squarefreeness. Condition (d) reads pq≤30pq \le 30. The unordered pairs of distinct primes with product at most 3030 are {2,3}, {2,5}, {2,7}, {2,11}, {2,13}, {3,5}, {3,7},\{2,3\},\ \{2,5\},\ \{2,7\},\ \{2,11\},\ \{2,13\},\ \{3,5\},\ \{3,7\}, seven in all, since 3⋅11=333 \cdot 11 = 33 and 5⋅7=355 \cdot 7 = 35 already exceed 3030. Here bb and cc play different roles, so each pair gives two triples, making 1414.

The cases cannot overlap, since a=b=1a = b = 1 would make ab=1ab = 1, which is not prime. The total is 3+14=173 + 14 = 17.

Answer 17

Solution: IOQM 2024, Q29

Key idea

Divisors of n2n^2 pair off as dd and n2/dn^2/d around nn, so exactly half of the ones other than nn are smaller than nn; subtract the divisors of nn that are smaller than nn.

With n=219312n = 2^{19}3^{12} we have n2=238324n^2 = 2^{38}3^{24}, so d(n2)=39⋅25=975,d(n)=20⋅13=260.d(n^2) = 39 \cdot 25 = 975, \qquad d(n) = 20 \cdot 13 = 260.

The divisors of n2n^2 come in pairs {d,n2/d}\{d, n^2/d\}, and the two members are equal only for d=nd = n. Of the remaining 974974 divisors, exactly one of each pair is less than nn, so #{d∣n2:d<n}=9742=487.\#\{d \mid n^2 : d < n\} = \frac{974}{2} = 487.

Among these, the ones that do divide nn are precisely the divisors of nn other than nn itself, of which there are 260−1=259260 - 1 = 259. Hence M=487−259=228,M = 487 - 259 = 228, and the last two digits are 2828.

Answer 28

Solution: IOQM 2025 Part SEP, Q28

Key idea

Writing KK for the continued fraction on the left, the expression is 1−1/K=1/(1+1/(K−1))1 - 1/K = 1/\bigl(1 + 1/(K-1)\bigr), and K−1K - 1 is the same continued fraction with its first term reduced by one.

Let K=2+13+14+15+16+17,K = 2 + \cfrac{1}{3 + \cfrac{1}{4 + \cfrac{1}{5 + \cfrac{1}{6 + \cfrac17}}}}, so the left-hand side is 1−1K=K−1K1 - \dfrac1K = \dfrac{K-1}{K}. Turning that upside down, K−1K=1KK−1=11+1K−1,\frac{K-1}{K} = \cfrac{1}{\dfrac{K}{K-1}} = \cfrac{1}{1 + \cfrac{1}{K-1}}, since KK−1=1+1K−1\dfrac{K}{K-1} = 1 + \dfrac{1}{K-1}.

Now read off the terms. Comparing with the required shape, x1=1x_1 = 1, and what remains is x2+1x3+⋯=K−1=1+13+14+15+16+17,x_2 + \cfrac{1}{x_3 + \cdots} = K - 1 = 1 + \cfrac{1}{3 + \cfrac{1}{4 + \cfrac{1}{5 + \cfrac{1}{6 + \cfrac17}}}}, because subtracting 11 from KK only changes its leading term from 22 to 11. So x2=1x_2 = 1 and then the rest is read straight off: x3=3,x4=4,x5=5,x6=6,x7=7.x_3 = 3, \quad x_4 = 4, \quad x_5 = 5, \quad x_6 = 6, \quad x_7 = 7. (This is the unique such expansion, since at each stage the integer part is forced.)

The sum is 1+1+3+4+5+6+7=271 + 1 + 3 + 4 + 5 + 6 + 7 = 27.

Answer 27

Solution: IOQM 2025 Part SEP, Q7

Key idea

The base repeats with period 77 and the exponent matters only modulo 66, so 4242 is a period; the work is showing that nothing smaller is.

For nn not divisible by 77, Fermat’s little theorem gives n6≡1(mod7)n^6 \equiv 1 \pmod 7. So (n+42)n+42≡nn+42=nn⋅(n6)7≡nn(mod7),(n+42)^{n+42} \equiv n^{n+42} = n^n \cdot \left(n^{6}\right)^{7} \equiv n^n \pmod 7, and when 7∣n7 \mid n both sides are 00. Hence 4242 is a period. The least positive period divides it: if 42=qT+r42=qT+r with 0≤r<T0\le r<T, then f(n+r)=f(n+r+qT)=f(n+42)=f(n)f(n+r)=f(n+r+qT)=f(n+42)=f(n) for every positive nn, so a positive rr would contradict the minimality of TT. Thus r=0r=0.

One observation cuts the divisors down: 77 must divide the period: if it did not, then some multiple of 77 would be sent to a non-multiple of 77, turning a value of 00 into a non-zero one. That leaves 77, 1414, 2121 and 4242.

Now test the three small ones against actual values, using f(2)=22=4f(2) = 2^2 = 4: Since the powers of 22 cycle as 2,4,12,4,1 modulo 77, f(9)=99≡29≡29 mod 3=20=1(mod7),f(9) = 9^9 \equiv 2^9 \equiv 2^{9 \bmod 3} = 2^0 = 1 \pmod 7, which is not 44, so T=7T = 7 fails. Likewise f(16)≡216≡21=2≠4,f(16) \equiv 2^{16} \equiv 2^{1} = 2 \ne 4, so T=14T = 14 fails. For T=21T = 21, use f(3)=33=27≡6f(3) = 3^3 = 27 \equiv 6 and f(24)≡324(mod7),f(24) \equiv 3^{24} \pmod 7, where 31,32,…,363^1,3^2,\ldots,3^6 leave remainders 3,2,6,4,5,13,2,6,4,5,1, and 24≡0(mod6)24 \equiv 0 \pmod 6, so f(24)≡1≠6f(24) \equiv 1 \ne 6.

Everything smaller having failed, the least period is T=42T = 42.

Answer 42

Solution: IOQM 2026, Q25

Key idea

The expression factorises as (p2−1)(p2+2)(p^2 - 1)(p^2 + 2). The first factor is always a multiple of 2424 and the second a multiple of 33, and two small primes show that nothing larger divides every member.

Factorise: p4+p2−2=(p2−1)(p2+2)p^4 + p^2 - 2 = (p^2 - 1)(p^2 + 2). The prime pp is odd and is not a multiple of 33.

The first factor is (p−1)(p+1)(p - 1)(p + 1), two consecutive even numbers, one of them a multiple of 44, so 88 divides it. One of p−1p - 1, pp, p+1p + 1 is a multiple of 33, and it is not pp, so 33 divides it too, and 2424 divides p2−1p^2 - 1. Since 33 divides p2−1p^2 - 1, the second factor p2+2=(p2−1)+3p^2 + 2 = (p^2 - 1) + 3 is a multiple of 33. So every member of EE is a multiple of 24×3=7224 \times 3 = 72.

Nothing larger works. With p=5p = 5 the member is 648=23⋅34648 = 2^3 \cdot 3^4, and with p=7p = 7 it is 2448=24⋅32⋅172448 = 2^4 \cdot 3^2 \cdot 17. A number dividing both divides 23⋅32=722^3 \cdot 3^2 = 72. The answer is 7272.

Answer 72

Solution: PRMO 2014, Q17

Key idea

The roots are a factor pair of bb, so N(b)N(b) is the number of unordered factorisations, and N(b)=20N(b) = 20 means bb has 3939 or 4040 divisors.

If x2+ax+b=0x^2 + ax + b = 0 has integer roots then, since their sum is −a<0-a < 0 and their product is b>0b > 0, both roots are negative: write them as −r-r and −s-s with rs=brs = b and a=r+sa = r + s.

Different factor pairs give different values of aa, because a pair is recovered from its sum and product. So N(b)N(b) is the number of unordered pairs {r,s}\{r, s\} with rs=brs = b, which is N(b)=⌈d(b)2⌉,N(b) = \left\lceil \frac{d(b)}{2} \right\rceil, where d(b)d(b) counts the divisors: the divisors pair up as rr with b/rb/r, with a middle divisor left over exactly when bb is a perfect square.

So N(b)=20N(b) = 20 means d(b)=39d(b) = 39 or d(b)=40d(b) = 40, and we want the smallest such bb.

Write b=p1e1p2e2⋯b = p_1^{e_1} p_2^{e_2} \cdots with the exponents in decreasing order. Then d(b)=(e1+1)(e2+1)⋯d(b) = (e_1+1)(e_2+1)\cdots, so a value of d(b)d(b) fixes the exponents up to a factorisation of that value into factors greater than one. For a given list of exponents the smallest bb puts the largest exponent on the smallest prime and uses the smallest primes available: swapping a larger exponent ee from a prime pp onto a smaller prime qq carrying f<ef < e divides bb by (p/q)e−f>1(p/q)^{e-f} > 1, and replacing any prime by a smaller unused one shrinks bb as well.

That leaves a finite list to inspect. For d(b)=40d(b) = 40 the seven factorisations and the smallest number each allows are exponents4,1,1,14,3,19,1,17,49,319,1smallest b16802160768010368138241572864\begin{array}{c|c|c|c|c|c|c} \text{exponents} & 4,1,1,1 & 4,3,1 & 9,1,1 & 7,4 & 9,3 & 19,1 \\ \hline \text{smallest } b & 1680 & 2160 & 7680 & 10368 & 13824 & 1572864 \end{array} together with the single exponent 3939, giving 2392^{39}. For d(b)=39d(b) = 39 the only factorisations are 3939 itself and 3×133 \times 13, giving 2382^{38} and 212⋅32=368642^{12} \cdot 3^2 = 36864.

The smallest entry anywhere in those two lists is b=1680=24⋅3⋅5⋅7,b = 1680 = 2^4 \cdot 3 \cdot 5 \cdot 7, and indeed d(1680)=5×2×2×2=40d(1680) = 5 \times 2 \times 2 \times 2 = 40, giving N(1680)=20N(1680) = 20.

Answer 1680

Solution: PRMO 2014, Q18

Key idea

f(999)=f(3)3f(37)f(999) = f(3)^3 f(37), and injectivity forces f(3)f(3) and f(37)f(37) to be different values at least 22, so the minimum is 23×32^3 \times 3.

Since 999=33×37999 = 3^3 \times 37 and ff is multiplicative, f(999)=f(3)3 f(37).f(999) = f(3)^3\,f(37).

Two constraints. First f(1)=f(1×1)=f(1)2f(1) = f(1 \times 1) = f(1)^2, and the only natural number equal to its own square is 11, since the natural numbers here start at 11. So f(1)=1f(1) = 1, and injectivity then forbids any other value from being 11: in particular f(3)≥2f(3) \ge 2 and f(37)≥2f(37) \ge 2. Second f(3)≠f(37)f(3) \ne f(37), again by injectivity.

So we are minimising u3vu^3 v over distinct integers u,v≥2u, v \ge 2, which is smallest at u=2u = 2, v=3v = 3: f(999)≥23×3=24.f(999) \ge 2^3 \times 3 = 24.

That bound is attained. Send the prime 33 to 22, the prime 3737 to 33, and permute the remaining primes among the primes left over, then extend multiplicatively. A permutation of the primes extends to a one-to-one map of the natural numbers onto themselves, by uniqueness of prime factorisation, so this ff is one-to-one and multiplicative, and f(999)=8×3=24f(999) = 8 \times 3 = 24.

Answer 24

Solution: PRMO 2017, Q28

Key idea

The condition on m=3pqm = 3pq turns out to be two clean statements: mm is squarefree, and ℓ−1\ell - 1 divides m−1m - 1 for each prime factor ℓ\ell. For m=3pqm = 3pq that reduces to p−1∣3q−1p-1 \mid 3q-1 and q−1∣3p−1q-1 \mid 3p-1, which leaves a short search.

A condition that holds for every nn can be tested one prime factor at a time. Write mm for the modulus 3pq3pq while we find the general rule. For a small warning about repeated prime factors, try m=9m=9 and n=3n=3: 39−3=3(38−1)3^9-3=3(3^8-1) has only one factor of 33, so it is not divisible by 99. This suggests starting with squarefreeness.

The criterion

Suppose m∣nm−nm \mid n^m - n for every nn. Then mm is squarefree: if ℓ2∣m\ell^2 \mid m then taking n=ℓn = \ell gives ℓ2∣ℓ(ℓm−1−1)\ell^2 \mid \ell(\ell^{m-1} - 1), so ℓ∣ℓm−1−1\ell \mid \ell^{m-1} - 1, which is false.

Next, for each prime ℓ∣m\ell \mid m we show ℓ−1∣m−1\ell - 1 \mid m - 1. Take any aa not divisible by ℓ\ell. From ℓ∣am−a=a(am−1−1)\ell \mid a^m - a = a(a^{m-1} - 1) we get am−1≡1(modℓ)a^{m-1} \equiv 1 \pmod \ell, and Fermat’s little theorem gives aℓ−1≡1a^{\ell-1} \equiv 1 as well. So two different exponents send aa to 11, and the first thing to notice is that their gcd does too.

Indeed, if aj≡1a^j \equiv 1 and ak≡1a^k \equiv 1 with j<kj < k, then ak−j≡1a^{k-j} \equiv 1 as well, since multiplying ak−ja^{k-j} by aja^j gives aka^k. The exponents that send aa to 11 are therefore closed under subtraction, which makes them exactly the multiples of the smallest of them: subtracting that smallest one repeatedly from any other member leaves a member, and the process cannot halt anywhere above zero. In particular the smallest exponent divides both m−1m-1 and ℓ−1\ell-1, so it divides their gcd dd, and hence ad≡1(modℓ),d=gcd⁡(m−1, ℓ−1),a^{d} \equiv 1 \pmod \ell, \qquad d = \gcd(m-1,\, \ell-1), for every one of the ℓ−1\ell - 1 non-zero remainders aa.

That is a great many solutions of one equation. The next step is to say that an equation of degree dd cannot have so many.

How many roots an equation can have modulo a prime

Over the ordinary numbers a polynomial of degree dd has at most dd roots, and the reason is the factor theorem: a root rr lets one write f(X)=(X−r)g(X)f(X) = (X-r)g(X) with gg of degree one less. The same proof works modulo a prime ℓ\ell, and that is the only property of primes it uses.

Dividing ff by X−rX - r leaves f(X)≡(X−r)g(X)+f(r)f(X) \equiv (X-r)g(X) + f(r), so a root rr gives f(X)≡(X−r)g(X)f(X) \equiv (X-r)g(X). If ss is another root then (s−r)g(s)≡0(s-r)g(s) \equiv 0 with s−r≢0s - r \not\equiv 0, and modulo a prime a product vanishes only when one factor does, so g(s)≡0g(s) \equiv 0. Every root therefore peels off a factor and drops the degree by one, and there can be at most dd of them.

Apply this to Xd−1X^d - 1. All ℓ−1\ell - 1 non-zero remainders are roots of it, so ℓ−1≤d\ell - 1 \le d. But dd divides ℓ−1\ell - 1, so d=ℓ−1d = \ell - 1 and therefore ℓ−1∣m−1\ell - 1 \mid m - 1.

The criterion, the other way round

Conversely, if mm is squarefree and ℓ−1∣m−1\ell - 1 \mid m - 1 for every prime ℓ∣m\ell \mid m, then each such ℓ\ell divides nm−nn^m - n: when ℓ∣n\ell \mid n both terms are multiples of ℓ\ell, and otherwise nm−1=(nℓ−1)(m−1)/(ℓ−1)≡1n^{m-1} = \left(n^{\ell-1}\right)^{(m-1)/(\ell-1)} \equiv 1 by Fermat’s little theorem. Being squarefree, mm divides nm−nn^m - n.

Applying it to m=3pqm = 3pq

Squarefreeness needs 33, pp, qq distinct. From ℓ=3\ell = 3 we need 2∣3pq−12 \mid 3pq - 1, so 3pq3pq is odd and neither pp nor qq is 22. From ℓ=p\ell = p, reduce modulo p−1p - 1: since p≡1p \equiv 1, 3pq−1≡3q−1(modp−1),sop−1∣3q−1,3pq - 1 \equiv 3q - 1 \pmod{p-1}, \qquad \text{so} \qquad p - 1 \mid 3q - 1, and symmetrically q−1∣3p−1q - 1 \mid 3p - 1.

Take p<qp < q, both odd primes other than 33. From q−1∣3p−1q - 1 \mid 3p - 1 we get q≤3pq \le 3p, so the search is finite.

  • p=5p = 5: q−1∣14q - 1 \mid 14 gives q∈{2,3,8,15}q \in \{2,3,8,15\}, none an allowed prime.

  • p=7p = 7: q−1∣20q - 1 \mid 20 allows q=11q = 11, but then p−1=6p - 1 = 6 must divide 3q−1=323q - 1 = 32, and it does not.

  • p=11p = 11: q−1∣32q - 1 \mid 32 gives q∈{2,3,5,9,17,33}q \in \{2,3,5,9,17,33\}, and q=17q = 17 is prime. Check the other condition: p−1=10p - 1 = 10 divides 3×17−1=503 \times 17 - 1 = 50. It works.

  • p=13p = 13: p−1=12p - 1 = 12 would have to divide 3q−13q - 1, which is never a multiple of 33. Impossible.

Any remaining pair has p≥17p \ge 17 and hence p+q>28p + q > 28. So the least value is p+q=11+17=28.p + q = 11 + 17 = 28.

The two conditions established at the start, squarefree and ℓ−1∣m−1\ell - 1 \mid m-1, are Korselt’s criterion. The number 3pq=3×11×17=5613pq = 3 \times 11 \times 17 = 561 that comes out of the search is the smallest Carmichael number, the first composite that passes Fermat’s test for every base.

Answer 28

Solution: PRMO 2017, Q29

Key idea

Any common factor is coprime to n!n!, so it divides n+1n+1; and Wilson’s theorem says n+1n+1 divides n!+1n!+1 exactly when n+1n+1 is prime.

Let d=hn=gcd⁡(n!+1,(n+1)!)d = h_n = \gcd(n! + 1, (n+1)!).

First, dd is coprime to n!n!, because a common factor of dd and n!n! would divide both n!n! and n!+1n! + 1, hence divide 11. Since (n+1)!=(n+1)⋅n!(n+1)! = (n+1)\cdot n!, it follows that d∣n+1.d \mid n + 1.

So hnh_n is at most n+1n+1. When p=n+1p=n+1 is prime, Wilson’s theorem shows that pp divides (p−1)!+1(p-1)!+1, and here is the proof of the case we need.

Modulo a prime pp, every non-zero remainder has a unique multiplicative inverse: multiplication by that remainder permutes the p−1p-1 non-zero remainders. The only remainders that are their own inverses are 11 and −1-1, since r2−1=(r−1)(r+1)r^2-1=(r-1)(r+1) and a prime dividing that product divides one factor. Pair all the others with their inverses. For example, modulo 55 the pair 2,32,3 has product 11, leaving 11 and 4=−14=-1. Every inverse pair has product 11, so (p−1)!≡−1(modp).(p-1)!\equiv -1\pmod p. For p=2p=2 this holds directly as well. Thus p∣(p−1)!+1p\mid(p-1)!+1 and hn=ph_n=p in the prime case.

If n+1n + 1 is composite, every prime factor of n+1n+1 is at most n+12≤n\tfrac{n+1}{2} \le n and so divides n!n!; but dd is coprime to n!n!, so d=1d = 1. Hence hn={n+1if n+1 is prime,1otherwise.h_n = \begin{cases} n+1 & \text{if } n+1 \text{ is prime},\\ 1 & \text{otherwise.} \end{cases}

For n<100n < 100 we want the largest prime of the form n+1n + 1 with n≤99n \le 99, that is the largest prime at most 100100. That is 9797, from n=96n = 96.

Answer 97

Solution: PRMO 2018, Q25

Key idea

The three remainder sets have only nine combinations that survive the moduli 1313 and 1515, and one of the nine already meets the condition modulo 1111 at its very first value.

We need a TT whose remainders satisfy T mod 11∈{7,8,9}T \bmod 11 \in \{7,8,9\}, and T mod 13∈{1,2,3}T \bmod 13 \in \{1,2,3\}, and T mod 15∈{4,5,6}T \bmod 15 \in \{4,5,6\}.

Start with the last two conditions, which fix TT modulo 195=13×15195 = 13 \times 15. The numbers below 195195 with remainder 44 on division by 1515 are 4,19,34,…,1844, 19, 34, \ldots, 184, and each step of 1515 raises the remainder modulo 1313 by 22, so their remainders modulo 1313 run 4, 6, 8, 10, 12, 1, 3, 5, 7, 9, 11, 0, 2.4,\ 6,\ 8,\ 10,\ 12,\ 1,\ 3,\ 5,\ 7,\ 9,\ 11,\ 0,\ 2. The ones in {1,2,3}\{1, 2, 3\} sit at 7979, 9494 and 184184. The same walk from 55 and from 66 finds three more each, 80,170,18580, 170, 185 and 66,81,17166, 81, 171, so nine possibilities in all: T≡66, 79, 80, 81, 94, 170, 171, 184, 185(mod195).T \equiv 66,\ 79,\ 80,\ 81,\ 94,\ 170,\ 171,\ 184,\ 185 \pmod{195}.

Now test the smallest representative of each against the condition modulo 1111. The first eight values in increasing order are 66,79,80,81,94,170,171,18466, 79, 80, 81, 94, 170, 171, 184, whose remainders modulo 1111 are 0, 2, 3, 4, 6, 5, 6, 8.0,\ 2,\ 3,\ 4,\ 6,\ 5,\ 6,\ 8. Only the last lies in {7,8,9}\{7,8,9\}. The ninth candidate, 185185, has remainder 99 and passes as well, but it is the larger of the two. Every other candidate has to be pushed up by at least one full period of 195195, which puts it past 184184.

So T=184T = 184, and one checks directly: 184=16⋅11+8184 = 16 \cdot 11 + 8, 184=14⋅13+2184 = 14 \cdot 13 + 2, 184=12⋅15+4184 = 12 \cdot 15 + 4. The sum of the squares of its digits is 1+64+16=81.1 + 64 + 16 = 81.

Answer 81

Solution: PRMO 2019, Q12

Key idea

Every k≥3k\ge3 is good: express 11 as a sum of kk distinct unit fractions and square their denominators to obtain the aia_i. The case k=2k=2 fails, and the remaining good numbers form a simple arithmetic progression.

Which kk are good

Suppose first that k=2k = 2, so 1/a+1/b=11/\sqrt{a} + 1/\sqrt{b} = 1 with a<ba < b. Then 1/a>121/\sqrt a > \tfrac12, so a<4a < 4, and a=1a = 1 is impossible since it already exhausts the sum. That leaves two cases, and both fail: a=2:b=11−1/2=2(2+1)=2+2,b=6+42,a = 2: \quad \sqrt b = \frac{1}{1 - 1/\sqrt2} = \sqrt2(\sqrt2 + 1) = 2 + \sqrt2, \quad b = 6 + 4\sqrt2, a=3:b=11−1/3=3+32,b=3+323,a = 3: \quad \sqrt b = \frac{1}{1 - 1/\sqrt3} = \frac{3+\sqrt3}{2}, \quad b = 3 + \tfrac32\sqrt3, and neither value of bb is an integer, 2\sqrt2 and 3\sqrt3 being irrational. So k=2k = 2 is not good.

Every k≥3k \ge 3 is good, and the construction is short. Write 11 as a sum of kk distinct unit fractions 1/n1+⋯+1/nk1/n_1 + \cdots + 1/n_k, then take ai=ni2a_i = n_i^2, so that 1/ai=1/ni1/\sqrt{a_i} = 1/n_i and the aia_i are distinct. Such a decomposition exists for every k≥3k \ge 3: start from 1=12+13+16,1 = \tfrac12 + \tfrac13 + \tfrac16, and to go from kk parts to k+1k+1 split the smallest part using 1n=1n+1+1n(n+1)\tfrac1n = \tfrac{1}{n+1} + \tfrac{1}{n(n+1)}, which replaces one denominator by two strictly larger ones and so keeps every denominator distinct.

The good numbers are therefore exactly 3,4,5,6,…3, 4, 5, 6, \ldots

The sum and the ratio

The first nn good numbers are 3,4,…,n+23, 4, \ldots, n+2, so f(n)=3+4+⋯+(n+2)=n(3+(n+2))2=n(n+5)2.f(n) = 3 + 4 + \cdots + (n+2) = \frac{n\bigl(3 + (n+2)\bigr)}{2} = \frac{n(n+5)}{2}. Hence f(n+5)f(n)=(n+5)(n+10)/2n(n+5)/2=n+10n=1+10n,\frac{f(n+5)}{f(n)} = \frac{(n+5)(n+10)/2}{n(n+5)/2} = \frac{n+10}{n} = 1 + \frac{10}{n}, the factor n+5n + 5 cancelling, which is the reason the problem shifted by exactly five. This is an integer precisely when nn divides 1010, that is n∈{1,2,5,10}n \in \{1, 2, 5, 10\}, and 1+2+5+10=18.1 + 2 + 5 + 10 = 18.

Answer 18

Solution: PRMO 2019, Q18

Key idea

Writing a=gda = gd and b=geb = ge with gcd⁡(d,e)=1\gcd(d,e) = 1 turns the condition into de=495de = 495, and 495495 has only four coprime splittings, after which the range 100≤a,b≤1000100 \le a, b \le 1000 counts the multipliers.

Let g=gcd⁡(a,b)g = \gcd(a,b) and write a=gda = gd, b=geb = ge with gcd⁡(d,e)=1\gcd(d,e) = 1. Then lcm⁡(a,b)=gde\operatorname{lcm}(a,b) = gde, so the ratio condition says ggde=1495,that isde=495.\frac{g}{gde} = \frac{1}{495}, \qquad \text{that is} \qquad de = 495.

Now 495=32×5×11495 = 3^2 \times 5 \times 11. A coprime splitting de=495de = 495 must give each prime power entirely to one side, so there are 23=82^3 = 8 ordered pairs and, imposing d<ed < e to match a<ba < b, exactly four: (d,e)=(1,495),(5,99),(9,55),(11,45).(d,e) = (1, 495), \quad (5, 99), \quad (9, 55), \quad (11, 45).

For each, the constraints are 100≤gd100 \le gd and ge≤1000ge \le 1000, since gd<gegd < ge makes the other two inequalities automatic.

  • (1,495)(1,495): needs g≥100g \ge 100 and g≤1000/495=2.02…g \le 1000/495 = 2.02\ldots, impossible.

  • (5,99)(5,99): needs g≥20g \ge 20 and g≤1000/99=10.1…g \le 1000/99 = 10.1\ldots, impossible.

  • (9,55)(9,55): needs g≥100/9=11.1…g \ge 100/9 = 11.1\ldots, so g≥12g \ge 12, and g≤1000/55=18.1…g \le 1000/55 = 18.1\ldots, so g≤18g \le 18. That is 77 values.

  • (11,45)(11,45): needs g≥100/11=9.09…g \ge 100/11 = 9.09\ldots, so g≥10g \ge 10, and g≤1000/45=22.2…g \le 1000/45 = 22.2\ldots, so g≤22g \le 22. That is 1313 values.

The two impossible cases are impossible for the same reason: a lopsided splitting forces bb to be hundreds of times aa, and the window from 100100 to 10001000 is only ten-fold. Adding the rest, 7+13=207 + 13 = 20 ordered pairs.

Answer 20

Solution: PRMO 2019, Q30

Key idea

The total n(n+1)/2n(n+1)/2 must be divisible by 33, which happens exactly when n≡0n \equiv 0 or 2(mod3)2 \pmod 3; and every such nn from 55 upwards really can be split, by four base cases and a jump of six.

The necessary condition

If {1,2,…,n}\{1, 2, \ldots, n\} splits into three subsets of equal sum, then 33 divides 1+2+⋯+n=n(n+1)/21 + 2 + \cdots + n = n(n+1)/2. Checking the three remainders of nn modulo 33, one finds n(n+1)/2n(n+1)/2 is a multiple of 33 exactly when n≡0 or 2(mod3),n \equiv 0 \text{ or } 2 \pmod 3, since n≡1n \equiv 1 makes both nn and n+1n+1 prime to 33.

The construction

Four base cases, each an explicit split into three parts of equal sum: n=5:{5}, {1,4}, {2,3}(each summing to 5)n=6:{1,6}, {2,5}, {3,4}(each 7)n=8:{4,8}, {5,7}, {1,2,3,6}(each 12)n=9:{6,9}, {7,8}, {1,2,3,4,5}(each 15)\begin{array}{ll} n = 5: & \{5\},\ \{1,4\},\ \{2,3\} \quad \text{(each summing to } 5) \\ n = 6: & \{1,6\},\ \{2,5\},\ \{3,4\} \quad \text{(each } 7) \\ n = 8: & \{4,8\},\ \{5,7\},\ \{1,2,3,6\} \quad \text{(each } 12) \\ n = 9: & \{6,9\},\ \{7,8\},\ \{1,2,3,4,5\} \quad \text{(each } 15) \end{array} And one step: given a valid split of {1,…,n}\{1, \ldots, n\}, the six new numbers n+1,…,n+6n+1, \ldots, n+6 form three pairs of equal sum 2n+72n + 7, namely {n+1,n+6},{n+2,n+5},{n+3,n+4},\{n+1, n+6\}, \quad \{n+2, n+5\}, \quad \{n+3, n+4\}, so handing one pair to each subset splits {1,…,n+6}\{1, \ldots, n+6\}. Since the four base cases 5,6,8,95, 6, 8, 9 cover the remainders 5,0,2,35, 0, 2, 3 modulo 66, and those are exactly the remainders allowed by the divisibility condition, every n≥5n \ge 5 satisfying it can be split.

The smallest cases are genuinely excluded and not merely awkward: for n=4n = 4 the total is 1010, which is not divisible by 33 at all, and in general nn must be at most a third of the total, which fails below n=5n = 5.

The count

So EE consists of the nn with 4<n<1004 < n < 100 and n≡0n \equiv 0 or 2(mod3)2 \pmod 3, together with the requirement n≥5n \ge 5, which excludes nothing further since n=4n = 4 already fails the divisibility. Counting from 55 to 9999: n≡0: 6,9,…,99 gives 32,n≡2: 5,8,…,98 gives 32.n \equiv 0: \ 6, 9, \ldots, 99 \ \text{gives } 32, \qquad n \equiv 2: \ 5, 8, \ldots, 98 \ \text{gives } 32. Hence ∣E∣=32+32=64|E| = 32 + 32 = 64.

Answer 64

Solution: IOQM 2020, Q25

Key idea

The four given numbers each sit just beside a square, and once their nearest squares are found the equation reduces to a single ratio, ⟨N⟩/N=21/22\langle N \rangle / N = 21/22, which forces NN into the family N=462m2N = 462m^2.

Begin by evaluating the four bracketed terms, each time comparing the distances to the squares on either side. For 9191 the neighbours are 8181 and 100100, at distances 1010 and 99, so ⟨91⟩=100\langle 91 \rangle = 100. For 120120 the neighbours are 100100 and 121121, at distances 2020 and 11, so ⟨120⟩=121\langle 120 \rangle = 121. Similarly ⟨143⟩=144\langle 143 \rangle = 144, being one below 144144, while 180180 sits between 169169 and 196196 at distances 1111 and 1616, so ⟨180⟩=169\langle 180 \rangle = 169.

The equation now reads 100⋅121⋅144⋅169⋅⟨N⟩=91⋅120⋅143⋅180⋅N,100 \cdot 121 \cdot 144 \cdot 169 \cdot \langle N \rangle = 91 \cdot 120 \cdot 143 \cdot 180 \cdot N, and rather than multiply everything out it is far easier to cancel prime by prime. Since 91=7⋅1391 = 7 \cdot 13 and 143=11⋅13143 = 11 \cdot 13, the right side carries 13213^2, which cancels against 169169; one factor of 1111 cancels against 121121; and the remaining 120⋅180100⋅144=2160014400=32\tfrac{120 \cdot 180}{100 \cdot 144} = \tfrac{21600}{14400} = \tfrac32 leaves ⟨N⟩N=7⋅311⋅2=2122.\frac{\langle N \rangle}{N} = \frac{7 \cdot 3}{11 \cdot 2} = \frac{21}{22}.

So ⟨N⟩=2122N\langle N \rangle = \tfrac{21}{22}N, which tells us two things at once. First, 2222 must divide NN, say N=22kN = 22k, whence ⟨N⟩=21k\langle N \rangle = 21k. Second, 21k21k has to be a perfect square, and since 21=3⋅721 = 3 \cdot 7 is square-free this forces k=21m2k = 21m^2. Putting these together, N=462m2,⟨N⟩=441m2=(21m)2.N = 462m^2, \qquad \langle N \rangle = 441m^2 = (21m)^2.

It remains to check that (21m)2(21m)^2 really is the nearest square to 462m2462m^2, since we derived the form from an equation, while the bracket has a meaning of its own, the nearest square. Taking the smallest case m=1m = 1, we have N=462N = 462 lying between 441=212441 = 21^2 and 484=222484 = 22^2, at distances 2121 and 2222 respectively, so the nearest square is indeed 441441. The smallest positive NN is therefore 462462, and the sum of the squares of its digits is 42+62+22=16+36+4=564^2 + 6^2 + 2^2 = 16 + 36 + 4 = 56.

Answer 56

Solution: IOQM 2021 Part B, Q2

Key idea

Modulo 33 the alternating weights all collapse to 11, so the sum is congruent to n(n+1)/2n(n+1)/2; that rules out n≡1n \equiv 1, and a three-step induction builds the rest.

Which nn are impossible

Since −2≡1(mod3)-2 \equiv 1 \pmod 3, every power (−2)i−1(-2)^{i-1} is congruent to 11, so for any permutation σ\sigma, ∑i=1nσ(i)(−2)i−1≡∑i=1nσ(i)=1+2+⋯+n=n(n+1)2(mod3).\sum_{i=1}^{n}\sigma(i)(-2)^{i-1} \equiv \sum_{i=1}^{n}\sigma(i) = 1 + 2 + \cdots + n = \frac{n(n+1)}{2} \pmod 3. The right-hand side is a multiple of 33 unless n≡1(mod3)n \equiv 1 \pmod 3, in which case it is ≡1\equiv 1. So for n≡1(mod3)n \equiv 1 \pmod 3 the sum can never be zero, whatever the permutation.

Which nn work

Every other nn does work, by induction in steps of three.

The two smallest cases are explicit. For n=2n = 2 take σ=(2,1)\sigma = (2,1), giving 2−2=02 - 2 = 0. For n=3n = 3 take σ=(2,3,1)\sigma = (2,3,1), giving 2−6+4=02 - 6 + 4 = 0.

To extend a working list, shift its entries up by 33 and move it two positions to the right. Its old zero sum stays zero, multiplied by (−2)2(-2)^2, but the added 33s contribute a geometric sum. The unused values 1,2,31,2,3 can cancel that correction: put 2,32,3 first and 11 last. For example, (2,1)(2,1) extends to (2,3,5,4,1)(2,3,5,4,1), whose weighted sum is 2−6+20−32+16=02-6+20-32+16=0.

Now suppose a permutation σ\sigma of 1,…,m1,\ldots,m works. The same arrangement for m+3m+3 is: τ(1)=2,τ(2)=3,τ(m+3)=1,\tau(1) = 2, \qquad \tau(2) = 3, \qquad \tau(m+3) = 1, τ(i)=σ(i−2)+3 for 3≤i≤m+2.\tau(i) = \sigma(i-2) + 3 \quad \text{ for } 3 \le i \le m+2. This is a permutation of 1,…,m+31, \ldots, m+3: the values 22, 33, 11 are used once each and the rest are σ\sigma shifted up by 33.

Its sum splits into the shifted copy of the old sum and a correction. The shifted copy contributes ∑i=3m+2(σ(i−2)+3)(−2)i−1=(−2)2∑j=1mσ(j)(−2)j−1⏟= 0+3∑i=3m+2(−2)i−1,\sum_{i=3}^{m+2}\bigl(\sigma(i-2)+3\bigr)(-2)^{i-1} = (-2)^{2}\underbrace{\sum_{j=1}^{m}\sigma(j)(-2)^{j-1}}_{=\,0} + 3\sum_{i=3}^{m+2}(-2)^{i-1}, and the geometric series evaluates as 3∑i=3m+2(−2)i−1=3⋅(−2)m+2−(−2)2−2−1=−((−2)m+2−4).3\sum_{i=3}^{m+2}(-2)^{i-1} = 3 \cdot \frac{(-2)^{m+2} - (-2)^{2}}{-2 - 1} = -\left((-2)^{m+2} - 4\right). Adding the three special terms 2⋅1+3⋅(−2)+1⋅(−2)m+22 \cdot 1 + 3 \cdot (-2) + 1 \cdot (-2)^{m+2}, ∑i=1m+3τ(i)(−2)i−1=2−6+(−2)m+2−(−2)m+2+4=0.\sum_{i=1}^{m+3}\tau(i)(-2)^{i-1} = 2 - 6 + (-2)^{m+2} - (-2)^{m+2} + 4 = 0.

So from n=2n = 2 and n=3n = 3 the construction reaches every larger nn congruent to 22 or 00 modulo 33, and the answer is n≡0  or  2(mod3).n \equiv 0 \ \text{ or } \ 2 \pmod 3.

Answer proof

Solution: IOQM 2022, Q8

Key idea

Rearrange to q(q−1)=p(197p−3)q(q-1) = p(197p-3). Since pp is prime and cannot equal qq, it must divide q−1q-1, and writing q−1=kpq - 1 = kp turns the problem into a single divisibility in kk.

Move everything to expose the factorisations: q2−q=197p2−3p,that isq(q−1)=p(197p−3).q^2 - q = 197p^2 - 3p, \qquad \text{that is} \qquad q(q-1) = p(197p - 3). The prime pp divides the right side, so it divides q(q−1)q(q-1), hence p=qp = q or p∣q−1p \mid q - 1. The case p=qp = q gives q2−q=197q2−3qq^2 - q = 197q^2 - 3q, so 196q2=2q196q^2 = 2q, which has no prime solution.

So write q−1=kpq - 1 = kp with kk a positive integer. Substituting q=kp+1q = kp+1, (kp+1)(kp)=p(197p−3)⟹k2p+k=197p−3,(kp+1)(kp) = p(197p - 3) \quad\Longrightarrow\quad k^2 p + k = 197p - 3, and gathering the terms in pp gives p(197−k2)=k+3p\left(197 - k^2\right) = k + 3.

Since pp and k+3k+3 are positive, we need k2<197k^2 < 197, so k≤14k \leq 14, and p=k+3197−k2p = \dfrac{k+3}{197 - k^2} must be a prime. For k≤13k \le 13 the denominator is at least 197−169=28197 - 169 = 28 while the numerator is at most 1616, so pp would be less than 11. That leaves only k=14k = 14: p=17197−196=17,p = \frac{17}{197 - 196} = 17, which is prime. Then q=14⋅17+1=239q = 14 \cdot 17 + 1 = 239, also prime.

Finally qp=23917=14+117\dfrac{q}{p} = \dfrac{239}{17} = 14 + \dfrac{1}{17}, so l=14l = 14, m=1m = 1, n=17n = 17, and l+m+n=32l + m + n = 32.

Answer 32

Solution: IOQM 2022, Q17

Key idea

The largest proper divisor of nn is n/pn/p where pp is the smallest prime factor, so f(n)=np−1pf(n) = n\frac{p-1}{p}. Running that backwards from 9797 branches only a little, and the smallest survivor is a prime.

If pp is the smallest prime factor of nn, then the largest proper divisor is g(n)=n/pg(n) = n/p, so f(n)=n−np=n⋅p−1p.f(n) = n - \frac{n}{p} = n \cdot \frac{p-1}{p}. In particular f(n)=n/2f(n) = n/2 for even nn, and for odd nn the factor p−1p\tfrac{p-1}{p} has an odd denominator. Rather than search forwards we invert the map three times, starting from 9797.

Solving f(m)=97f(m) = 97

If mm is even then m/2=97m/2 = 97 and m=194m = 194. If mm is odd with least prime pp, then m=97pp−1m = \tfrac{97p}{p-1}, and since p−1p-1 is coprime to pp we need p−1∣97p - 1 \mid 97, so p=2p = 2, which is not odd, or p=98p = 98, which is not prime. So m=194m = 194 uniquely.

Solving f(k)=194f(k) = 194

Even kk gives k=388k = 388. Odd kk needs p−1∣194p - 1 \mid 194, so p∈{2,3,98,195}p \in \{2, 3, 98, 195\}, of which only p=3p = 3 is an odd prime, giving k=194⋅32=291=3⋅97k = \tfrac{194 \cdot 3}{2} = 291 = 3 \cdot 97, whose least prime really is 33. So k∈{388, 291}k \in \{388,\ 291\}.

Solving f(N)=388f(N) = 388 or f(N)=291f(N) = 291

From 388388: even NN gives 776776; odd NN needs p−1∣388p-1 \mid 388, so p∈{2,3,5,98,195,389}p \in \{2,3,5,98,195,389\}. Here p=3p = 3 would give the even number 582582, a contradiction; p=5p = 5 gives N=388⋅54=485=5⋅97N = \tfrac{388 \cdot 5}{4} = 485 = 5 \cdot 97, valid; and p=389p = 389 gives N=389N = 389, a prime, for which f(389)=389−1=388f(389) = 389 - 1 = 388, also valid. From 291291: even NN gives 582582, and odd NN needs p−1∣291p - 1 \mid 291, which offers no odd prime.

The candidates are 776776, 582582, 485485 and 389389, so the smallest is N=389N = 389. Since 192=36119^2 = 361 and 202=40020^2 = 400, the largest integer not exceeding 389\sqrt{389} is 1919.

Answer 19

Solution: IOQM 2022, Q18

Key idea

Factor out the gcd. The equation becomes g⋅(integer)=5g \cdot (\text{integer}) = 5, so gg is 11 or 55, and each case is a small factorisation.

Write g=gcd⁡(m,n)g = \gcd(m,n) with m=gam = ga and n=gbn = gb, where gcd⁡(a,b)=1\gcd(a,b) = 1, so that LCM(m,n)=gab\mathrm{LCM}(m,n) = gab. The equation becomes ga+3gb−5=2gab−11g,ga + 3gb - 5 = 2gab - 11g, that is, g(a+3b−2ab+11)=5.g\bigl(a + 3b - 2ab + 11\bigr) = 5. Since gg is a positive integer dividing 55, either g=1g = 1 or g=5g = 5, and the bracket takes the complementary value.

The case g=5g = 5, which is where the maximum lives

Here a+3b−2ab+11=1a + 3b - 2ab + 11 = 1, so 2ab−a−3b=102ab - a - 3b = 10. Multiplying by 22 to make it factor, 4ab−2a−6b=204ab - 2a - 6b = 20, and adding 33 to both sides, (2a−3)(2b−1)=23.(2a - 3)(2b - 1) = 23. As 2323 is prime, the positive possibilities are (2a−3,2b−1)=(1,23)(2a-3, 2b-1) = (1, 23) or (23,1)(23, 1). The first gives a=2a = 2, b=12b = 12, which fails because gcd⁡(2,12)≠1\gcd(2,12) \neq 1. The second gives a=13a = 13, b=1b = 1, which is coprime, so m=65m = 65 and n=5n = 5, and m+n=70m + n = 70.

The case g=1g = 1

Now a+3b−2ab+11=5a + 3b - 2ab + 11 = 5, and the same manipulation gives (2a−3)(2b−1)=15(2a-3)(2b-1) = 15. Here 2b−12b - 1 is positive, so 2a−32a - 3 is too, and the four factorisations of 1515 give (a,b)=(2,8),(3,3),(4,2),(9,1).(a, b) = (2, 8), \quad (3, 3), \quad (4, 2), \quad (9, 1). The first three share a factor, so only a=9a = 9, b=1b = 1 is coprime, giving m=9m = 9, n=1n = 1 and m+n=10m + n = 10.

The larger of the two is 7070.

Answer 70

Solution: IOQM 2023, Q29

Key idea

Ones may be padded on freely, so a representation is really a factorisation of nn into factors at least 22; uniqueness therefore says nn is a product of exactly two primes.

Suppose n=a1a2⋯ak=a1+a2+⋯+akn = a_1 a_2 \cdots a_k = a_1 + a_2 + \cdots + a_k. The factors equal to 11 do not affect the product, and each adds 11 to the sum, so a representation is completely described by the factors that exceed 11, listed with repeats and in no particular order: if those are b1,…,bjb_1, \ldots, b_j with product nn and sum tt, the number of ones is forced to be n−tn - t.

That number of ones is never negative. For j≥2j \ge 2 factors each at least 22, b1b2⋯bj≥b1+b2+⋯+bj,b_1b_2\cdots b_j \ge b_1 + b_2 + \cdots + b_j, which for two factors is (b1−1)(b2−1)≥1(b_1-1)(b_2-1) \ge 1 and follows for more factors by repeating the step. So every factorisation of nn into two or more factors, each at least 22, gives exactly one valid representation, and every representation arises this way.

Uniqueness therefore means: nn has exactly one factorisation into two or more factors greater than 11. A prime has none at all, so primes are not beautiful. If nn has three prime factors counted with multiplicity, say n=pqrn = pqr, then n=p⋅qrn = p \cdot qr and n=p⋅q⋅rn = p \cdot q \cdot r are two different factorisations, so nn is not beautiful; and the same applies with more factors. That leaves exactly the numbers with two prime factors counted with multiplicity, n=pqn = pq, whose only factorisation is p⋅qp \cdot q.

So the beautiful numbers are the products of two primes. Checking downwards from 9999: 99=32⋅1199 = 3^2 \cdot 11 has three prime factors, 98=2⋅7298 = 2 \cdot 7^2 has three, 9797 is prime, 9696 has many, and 95=5⋅1995 = 5 \cdot 19 is a product of two primes. The largest beautiful number below 100100 is 9595.

The example in the problem is worth revisiting with this in hand: 8=238 = 2^3 has the two factorisations 2⋅42 \cdot 4 and 2⋅2⋅22 \cdot 2 \cdot 2, which are exactly the two representations displayed there.

Answer 95

Solution: IOQM 2023, Q30

Key idea

d(i)d(i) is odd only for perfect squares, so the running total is odd exactly when ⌊n⌋\lfloor \sqrt n \rfloor is odd.

The first few divisor counts and running sums show where the parity changes: n123456789d(n)122324243∑i=1nd(i)13581014162023\begin{array}{c|rrrrrrrrr} n&1&2&3&4&5&6&7&8&9\\\hline d(n)&1&2&2&3&2&4&2&4&3\\ \sum_{i=1}^n d(i)&1&3&5&8&10&14&16&20&23 \end{array} The running sum changes parity at 1,4,91,4,9, the squares. Divisor pairing explains that pattern.

Divisors come in pairs ee and m/em/e, and the two coincide only when mm is a perfect square. So d(m)d(m) is odd exactly when mm is a perfect square, and therefore ∑i=1nd(i)≡#{perfect squares≤n}=⌊n⌋(mod2).\sum_{i=1}^{n} d(i) \equiv \#\{\text{perfect squares} \le n\} = \lfloor \sqrt n \rfloor \pmod 2. The sum is odd exactly when ⌊n⌋\lfloor \sqrt n \rfloor is odd.

Now count such n≤2023n \le 2023. The integers with ⌊n⌋=k\lfloor \sqrt n \rfloor = k are those from k2k^2 to (k+1)2−1(k+1)^2 - 1, and there are 2k+12k+1 of them. Since 442=1936≤2023<2025=45244^2 = 1936 \le 2023 < 2025 = 45^2, the value of kk runs from 11 to 4444, and the largest odd kk is 4343, whose block ends at 442−1=193544^2 - 1 = 1935, comfortably inside the range. So no block with odd kk is cut short, and r=∑k odd1≤k≤43(2k+1).r = \sum_{\substack{k \text{ odd} \\ 1 \le k \le 43}} (2k+1). There are 2222 odd values of kk, and their sum is 1+3+⋯+43=222=4841 + 3 + \cdots + 43 = 22^2 = 484, so r=2⋅484+22=990.r = 2 \cdot 484 + 22 = 990.

The sum of the digits of 990990 is 9+9+0=189 + 9 + 0 = 18.

Answer 18

Solution: IOQM 2024, Q18

Key idea

Since r=100p+q=100(p+q)−99qr = 100p + q = 100(p+q) - 99q and p+qp+q shares no factor with qq, the condition p+q∣rp + q \mid r says exactly that p+qp+q divides 9999.

Write r=100p+qr = 100p + q. Then r=100(p+q)−99q,r = 100(p+q) - 99q, so p+qp + q divides rr exactly when p+qp+q divides 99q99q. Now gcd⁡(p+q,q)=gcd⁡(p,q)=1\gcd(p+q, q) = \gcd(p,q) = 1, so

this happens exactly when (p+q)∣99.(p+q) \mid 99.

The divisors of 9999 are 1,3,9,11,33,991, 3, 9, 11, 33, 99. Both pp and qq are two-digit, so p+q≥20p + q \ge 20, leaving only 3333 and 9999.

To make rr large we want pp as large as possible, and p+q=99p + q = 99 allows a much larger pp than p+q=33p+q = 33 does, where p≤22p \le 22 and hence r≤2211r \le 2211. So take p+q=99p + q = 99 and work downward from the largest admissible pp, remembering that qq must be two-digit and not a multiple of 1010, and that gcd⁡(p,q)=1\gcd(p,q) = 1: p=88, q=11:gcd⁡=11;p=87, q=12:gcd⁡=3;p = 88,\ q = 11: \gcd = 11; \qquad p = 87,\ q = 12: \gcd = 3; p=86, q=13:gcd⁡=1.p = 86,\ q = 13: \gcd = 1. So the largest printed number is N=8613N = 8613, and a check confirms 8613=99⋅878613 = 99 \cdot 87.

The last two digits are 1313.

Answer 13

Solution: IOQM 2024, Q23

Key idea

Modulo nn the fourth powers of xx and n−xn-x agree, so most small nn fail immediately; 3131 works because the only fourth roots of unity modulo 3131 are ±1\pm1.

The move that decides this problem is worth naming before it is used. We are not trying to work out what the fourth powers modulo nn actually are. We are trying to manufacture two different numbers in the range 11 to 1414 that are forced to share a fourth power, because one such pair kills that value of nn outright.

The cheapest manufacturer is (n−x)4≡x4(modn)(n-x)^4 \equiv x^4 \pmod n, so any nn for which two of 1,…,141, \ldots, 14 add up to nn is ruled out at once. For 15≤n≤2715 \le n \le 27 take the pair 1414 and n−14n - 14, which are distinct and both in range. That disposes of everything from 1515 to 2727, and n≤13n \le 13 is impossible because fourteen numbers cannot have fourteen distinct remainders modulo 1313 or less, while n=14n = 14 falls to the pair 11 and 1313.

Three cases remain below 3131.

  • n=28n = 28: 134−14=(132−1)(132+1)=168⋅17013^4 - 1^4 = (13^2-1)(13^2+1) = 168 \cdot 170, and 168=6⋅28168 = 6 \cdot 28, so 11 and 1313 collide.

  • n=29n = 29: here 122=144=5⋅29−1≡−112^2 = 144 = 5 \cdot 29 - 1 \equiv -1, so (12x)4=(122)2x4≡x4(12x)^4 = \left(12^2\right)^2 x^4 \equiv x^4. Hence xx, −x-x, 12x12x and −12x-12x all share a fourth power, and for x≢0x \not\equiv 0 these four are distinct, since 11, −1-1, 1212 and −12-12 are distinct modulo 2929. The 2828 non-zero remainders therefore fall into seven groups of four, leaving only seven possible fourth powers, which cannot accommodate fourteen numbers.

  • n=30n = 30: 74=2401=80⋅30+17^4 = 2401 = 80 \cdot 30 + 1, so 77 and 11 collide.

Now take n=31n = 31, and suppose t4≡1t^4 \equiv 1. Then (t2)2≡1\left(t^2\right)^2 \equiv 1, and modulo a prime u2≡1u^2 \equiv 1 forces u≡±1u \equiv \pm 1, so t2≡±1t^2 \equiv \pm 1. The minus sign is impossible, because it would give t30=(t2)15≡(−1)15=−1,t^{30} = \left(t^2\right)^{15} \equiv (-1)^{15} = -1, contradicting Fermat’s little theorem. So t2≡1t^2 \equiv 1 and t≡±1t \equiv \pm 1. To finish without dividing remainders, suppose x4≡y4(mod31)x^4\equiv y^4\pmod{31} for 1≤x<y≤141\le x<y\le14. Then (x−y)(x+y)(x2+y2)≡0(mod31).(x-y)(x+y)(x^2+y^2)\equiv0\pmod{31}. The prime 3131 divides neither x−yx-y nor x+yx+y, since 0<y−x<310<y-x<31 and x+y≤27x+y\le27. It must therefore divide x2+y2x^2+y^2, giving x2≡−y2x^2\equiv-y^2. Raising to the fifteenth power gives x30≡−y30x^{30}\equiv-y^{30}, but Fermat’s theorem makes these two sides 11 and −1-1. This contradiction shows that no two such fourth powers coincide. So the fourteen fourth powers are distinct modulo 3131, and 3131 is the smallest such nn.

Answer 31

Solution: IOQM 2024, Q28

Key idea

The expression factors as (n−1)(n+1)(n2+1)(n2+2n+2)(n2−2n+2)(n-1)(n+1)(n^2+1)(n^2+2n+2)(n^2-2n+2) over 22, and for every nn from 2121 to 2929 some small prime, usually 22 or 55, appears twice among those factors.

First factorise. Treating it as a quadratic in n4n^4, n8+3n4−4=(n4+4)(n4−1),n^8 + 3n^4 - 4 = (n^4 + 4)(n^4 - 1), and each part factors further: n4−1=(n−1)(n+1)(n2+1)n^4 - 1 = (n-1)(n+1)(n^2+1), while completing a square gives n4+4=(n2+2)2−(2n)2=(n2+2n+2)(n2−2n+2).n^4+4=(n^2+2)^2-(2n)^2=(n^2+2n+2)(n^2-2n+2). So 12(n8+3n4−4)=12(n−1)(n+1)(n2+1)(n2+2n+2)(n2−2n+2).\tfrac12\left(n^8+3n^4-4\right) = \tfrac12 (n-1)(n+1)(n^2+1)(n^2+2n+2)(n^2-2n+2).

For the whole thing to be squarefree, no odd prime may divide two factors or occur twice in one factor. For 22, the division by 22 removes one copy, so we must count its copies before cancelling. Two obstructions recur.

The prime 22: for odd nn, both n−1n-1 and n+1n+1 are even and n2+1n^2+1 is even as well, so 88 divides the product and a single division by 22 cannot rescue it. That rules out every odd nn at a stroke, in particular 21,23,25,27,2921, 23, 25, 27, 29.

That leaves the four even values 22,24,26,2822, 24, 26, 28, and each falls to a single visible square: n=22: 5∣485=n2+1 and 5∣530=n2+2n+2;n = 22: \ 5 \mid 485 = n^2+1 \text{ and } 5 \mid 530 = n^2+2n+2; n=24: n+1=25;n = 24: \ n+1 = 25; n=26: n−1=25;n=28: n−1=27=33.n = 26: \ n-1 = 25; \qquad n = 28: \ n-1 = 27 = 3^3.

Now test n=20n = 20: 12⋅19⋅21⋅401⋅442⋅362=19⋅3⋅7⋅401⋅(2⋅13⋅17)⋅181,\tfrac12 \cdot 19 \cdot 21 \cdot 401 \cdot 442 \cdot 362 = 19 \cdot 3 \cdot 7 \cdot 401 \cdot (2 \cdot 13 \cdot 17) \cdot 181, after cancelling the 22, and every prime here, namely 2,3,7,13,17,19,181,4012, 3, 7, 13, 17, 19, 181, 401, occurs once. So the value is squarefree and the answer is n=20.n = 20.

Answer 20

Solution: IOQM 2025 Part SEP, Q28

Key idea

Writing j=n2j = n^2, the equation m2+j2=2km^2 + j^2 = 2^k forces m=jm = j, because two squares summing to a power of two must be equal.

Set j=n2j = n^2, so the condition is m2+j2=2km^2 + j^2 = 2^k for some kk.

Suppose mm and jj are both odd. Then m2≡j2≡1(mod8)m^2 \equiv j^2 \equiv 1 \pmod 8, so their sum is 2(mod8)2 \pmod 8, which is a power of two only if the sum is 22 itself, giving m=j=1m = j = 1. If one is odd and the other even, the sum is odd and larger than 11, which is impossible. So they are both even, and dividing the equation by 44 returns the same problem for m/2m/2 and j/2j/2.

Descending in this way, we reach the odd case, so m=j=2sm = j = 2^s for some s≥0s \ge 0. Since j=n2j = n^2, that means n2=2sn^2 = 2^s, so ss is even, and writing s=2rs = 2r gives n=2r,m=22r=n2.n = 2^r, \qquad m = 2^{2r} = n^2.

Finally the bounds. We need m=4r≤20000m = 4^r \le 20000, and 47=163844^7 = 16384 while 48=655364^8 = 65536, so rr runs from 00 to 77; the condition on n=2rn = 2^r is then automatic. That is 88 ordered pairs.

Answer 8

Solution: IOQM 2025 Part SEP, Q28

Key idea

The two sides of the equation are the numerator and denominator of the continued fraction a+1b+1c+1da + \cfrac{1}{b + \cfrac{1}{c + \cfrac1d}}, so the equation says that this equals 2017\tfrac{20}{17}.

The two brackets are linked by repeated quotient and remainder. Write U=abcd+ab+ad+cd+1U=abcd+ab+ad+cd+1, V=bcd+b+dV=bcd+b+d and W=cd+1W=cd+1. Then U=aV+W,V=bW+d,W=cd+1.U=aV+W,\qquad V=bW+d,\qquad W=cd+1. Dividing the first equation by VV, then using the other two to read V/WV/W, gives a sequence of reciprocals. This is why a continued fraction is useful. Build it from the inside: c+1d=cd+1d,b+dcd+1=bcd+b+dcd+1,c + \frac1d = \frac{cd+1}{d}, \qquad b + \frac{d}{cd+1} = \frac{bcd + b + d}{cd+1}, a+cd+1bcd+b+d=abcd+ab+ad+cd+1bcd+b+d.a + \frac{cd+1}{bcd+b+d} = \frac{abcd + ab + ad + cd + 1}{bcd+b+d}. The numerator and denominator on the right are exactly the two brackets in the problem, so the given equation says a+1b+1c+1d=2017.a + \cfrac{1}{b + \cfrac{1}{c + \cfrac{1}{d}}} = \frac{20}{17}.

Now expand 2017\tfrac{20}{17} as a continued fraction, which is just repeated division: 2017=1+317=1+1173=1+15+23=1+15+11+12.\frac{20}{17} = 1 + \frac{3}{17} = 1 + \cfrac{1}{\tfrac{17}{3}} = 1 + \cfrac{1}{5 + \tfrac23} = 1 + \cfrac{1}{5 + \cfrac{1}{1 + \tfrac12}}. So a=1a = 1, b=5b = 5, c=1c = 1, d=2d = 2, and this is the only expansion with four positive integer terms, since at each stage the integer part is forced.

Hence a2+b2+c2+d2=1+25+1+4=31.a^2+b^2+c^2+d^2 = 1 + 25 + 1 + 4 = 31.

Answer 31

Solution: IOQM 2025 Part SEP, Q28

Key idea

mnmn is a square exactly when mm and nn have the same squarefree part, so group the numbers by that and count pairs inside each group.

Write each integer as kt2k t^2 with kk squarefree; the number kk is its squarefree part. Then mnmn is a perfect square precisely when mm and nn have the same squarefree part, because mn=kmkn(tmtn)2mn = k_mk_n (t_mt_n)^2 and kmknk_mk_n is a square only when km=knk_m = k_n, both being squarefree.

So sort 1,…,501, \ldots, 50 into classes by squarefree part. A class with squarefree part kk consists of the numbers k,4k,9k,…k, 4k, 9k, \ldots up to 5050, and only k≤12k \le 12 can give a class with more than one member: kclass(∣class∣2)11,4,9,16,25,36,492122,8,18,32,501033,12,27,48655,20,45366,24177,2811010,4011111,441\begin{array}{r|l|c} k & \text{class} & \binom{|class|}{2} \\ \hline 1 & 1,4,9,16,25,36,49 & 21 \\ 2 & 2,8,18,32,50 & 10 \\ 3 & 3,12,27,48 & 6 \\ 5 & 5,20,45 & 3 \\ 6 & 6,24 & 1 \\ 7 & 7,28 & 1 \\ 10 & 10,40 & 1 \\ 11 & 11,44 & 1 \end{array} Every other class is a single number and contributes nothing.

Adding up, the number of pairs with m<nm < n is 21+10+6+3+1+1+1+1=44.21 + 10 + 6 + 3 + 1 + 1 + 1 + 1 = 44.

Answer 44

Solution: IOQM 2025 Part SEP, Q28

Key idea

Modulo 77 the powers of 22 repeat every 33 steps and the squares every 77, so the whole condition repeats every 2121, and 105105 is exactly five such blocks.

Modulo 77 we have 23=8≡12^3 = 8 \equiv 1, so 2n2^n depends only on nn modulo 33; and n2n^2 depends only on nn modulo 77. So whether 7∣2n−n27 \mid 2^n - n^2 depends only on nn modulo 2121, and since 105=5⋅21105 = 5 \cdot 21, it is enough to count the good remainders in one block of 2121 and multiply by 55.

The two tables are short. The powers cycle as 2n≡2,4,1for n≡1,2,0(mod3),2^n \equiv 2, 4, 1 \quad \text{for } n \equiv 1, 2, 0 \pmod 3, and the squares are n2≡0,1,4,2,2,4,1for n≡0,1,…,6(mod7).n^2 \equiv 0,1,4,2,2,4,1 \quad \text{for } n \equiv 0,1,\ldots,6 \pmod 7. Each value 11, 22, 44 that 2n2^n can take is a square for exactly two remainders modulo 77, so for each remainder of nn modulo 33 there are two good remainders modulo 77: n mod 32n mod 7n mod 7 with n2≡2n011,6123,4242,5\begin{array}{c|c|c} n \bmod 3 & 2^n \bmod 7 & n \bmod 7 \text{ with } n^2 \equiv 2^n \\ \hline 0 & 1 & 1, 6 \\ 1 & 2 & 3, 4 \\ 2 & 4 & 2, 5 \end{array} A remainder modulo 33 and one modulo 77 cannot belong to two different numbers in one block of 2121: their difference would be divisible by both 33 and 77, hence by 2121. The six numbers listed below realise all six allowed combinations, so the good remainders number 3×2=63 \times 2 = 6. In 1,…,211, \ldots, 21 they are n=2, 4, 5, 6, 10, 15.n = 2,\ 4,\ 5,\ 6,\ 10,\ 15. For instance n=4n = 4 gives 24≡22^4 \equiv 2 and 42=16≡24^2 = 16 \equiv 2, while n=7n = 7 gives 27≡22^7 \equiv 2 but 72≡07^2 \equiv 0.

Hence the count up to 105105 is 6⋅5=306 \cdot 5 = 30.

Answer 30

Solution: IOQM 2026, Q29

Key idea

Here 3n=262−13n = 2^{62} - 1, so 2622^{62} leaves remainder 11 on division by nn. Everything then turns on whether 6262 divides n−1n - 1, and it does.

Since 431=2624^{31} = 2^{62}, the definition says 3n=262−13n = 2^{62} - 1, so 262=3n+12^{62} = 3n + 1 leaves remainder 11 on division by nn. Every power (262)m\bigl(2^{62}\bigr)^m then leaves remainder 11 as well, being a product of numbers each one more than a multiple of nn.

Now look at n−1n - 1: n−1=431−13−1=431−43=4⋅430−13.n - 1 = \frac{4^{31} - 1}{3} - 1 = \frac{4^{31} - 4}{3} = 4 \cdot \frac{4^{30} - 1}{3}. The fraction is a whole number, since 430−14^{30} - 1 is a multiple of 4−1=34 - 1 = 3, so n−1n - 1 is even. It is also a multiple of 3131. Since 25=32=31+12^5 = 32 = 31 + 1, the power 430=(25)124^{30} = (2^5)^{12} leaves remainder 11 on division by 3131, so 3131 divides 430−14^{30} - 1, and as 3131 shares no factor with 33 it divides (430−1)/3(4^{30} - 1)/3.

So 6262 divides n−1n - 1. Writing n−1=62mn - 1 = 62m, the number 2n−1=(262)m2^{n-1} = \bigl(2^{62}\bigr)^m leaves remainder 11 on division by nn.

Answer 1

Solution: PRMO 2019, Q20

Key idea

The three congruence conditions describe remainder classes modulo 11×12×1311 \times 12 \times 13, and a remainder class contains arbitrarily large numbers, so the set EE has no largest element at all.

This question was discounted by the organisers, and the reason is visible as soon as the conditions are unpicked. The official key prints a dash against it.

Start with what the conditions allow. Let the remainders be r1r_1, r2r_2, r3r_3 on division by 1111, 1212, 1313, so r1≤10r_1 \le 10, r2≤11r_2 \le 11 and r3≤12r_3 \le 12. They are to be distinct primes forming an arithmetic progression in that order, so r1+r3=2r2r_1 + r_3 = 2r_2. The primes available are 2,3,5,72, 3, 5, 7 for r1r_1 and 2,3,5,7,112, 3, 5, 7, 11 for the other two. The prime 22 cannot appear: as r1r_1 or r3r_3 it would make r1+r3r_1 + r_3 odd, and as r2r_2 it would need r1+r3=4r_1 + r_3 = 4 from two distinct primes. With odd primes only, r2=3r_2 = 3 would need r1+r3=6r_1 + r_3 = 6 from distinct primes, which is impossible; r2=5r_2 = 5 needs r1+r3=10r_1 + r_3 = 10, giving 33 and 77 in either order; r2=7r_2 = 7 needs 14=3+1114 = 3 + 11, and r1≤10r_1 \le 10 puts the 33 first; r2=11r_2 = 11 needs 2222, which no two allowed primes reach. That leaves exactly three triples: (3,5,7),(7,5,3),(3,7,11).(3,5,7), \qquad (7,5,3), \qquad (3,7,11).

Each triple has a representative, checked directly: 1697=11⋅154+3=12⋅141+5=13⋅130+7,1697=11\cdot154+3=12\cdot141+5=13\cdot130+7, 29=11⋅2+7=12⋅2+5=13⋅2+3,29=11\cdot2+7=12\cdot2+5=13\cdot2+3, 1675=11⋅152+3=12⋅139+7=13⋅128+11.1675=11\cdot152+3=12\cdot139+7=13\cdot128+11. Any two numbers giving the same triple have a difference divisible by 1111, 1212 and 1313, hence by their product 17161716, since the three moduli are pairwise coprime. Thus the three possibilities are n≡1697,n≡29,n≡1675(mod1716).n \equiv 1697, \qquad n \equiv 29, \qquad n \equiv 1675 \pmod{1716}.

And here the question breaks. The set EE is the union of three remainder classes modulo 17161716, each of which is infinite: if nn lies in EE then so do n+1716n + 1716, n+3432n + 3432 and every further step. So EE has no largest element, and the phrase “the largest number in EE” does not refer to anything.

The intended reading was surely one full cycle, that is the largest nn below 17161716, which is 16971697 and has digit sum 1+6+9+7=231 + 6 + 9 + 7 = 23. It is worth writing that out because the working above is a perfectly good exercise in the Chinese remainder theorem. But an answer of 2323 needs a hypothesis the paper never states, and the discounting was correct.

Answer none

Solution: IOQM 2020, Q30

Key idea

Reducing a2+a+2a^2+a+2 modulo a+1a+1 leaves a remainder of 22, and chasing that through the divisibility forces a2+a+2=2ba^2+a+2 = 2b exactly. After that the problem is a range check and a parity check.

The two conditions pull in different directions, so the aim is to make them meet. Since a+1a+1 divides b−1b-1, write b=k(a+1)+1b = k(a+1) + 1. Since bb divides a2+a+2a^2+a+2, write a2+a+2=mba^2 + a + 2 = mb for some positive integer mm. The useful observation is that a2+a+2=a(a+1)+2≡2(moda+1),a^2 + a + 2 = a(a+1) + 2 \equiv 2 \pmod{a+1}, while b≡1(moda+1)b \equiv 1 \pmod{a+1} by construction. Reducing a2+a+2=mba^2+a+2 = mb modulo a+1a+1 therefore gives m≡2(moda+1)m \equiv 2 \pmod{a+1}, so m=2+j(a+1)m = 2 + j(a+1) for some integer j≥0j \geq 0.

Now show that jj has to be zero. Substituting both expressions into a(a+1)+2=mba(a+1) + 2 = mb and expanding, a(a+1)+2=(2+j(a+1))(k(a+1)+1),a(a+1) + 2 = \bigl(2 + j(a+1)\bigr)\bigl(k(a+1)+1\bigr), whose right-hand side expands to 2k(a+1)+2+jk(a+1)2+j(a+1),2k(a+1) + 2 + jk(a+1)^2 + j(a+1), and cancelling the 22 from each side and then dividing through by a+1a+1 leaves a=2k+j+jk(a+1).a = 2k + j + jk(a+1). If j≥1j \geq 1 and k≥1k \geq 1 then the single term jk(a+1)jk(a+1) already exceeds aa, which is impossible, and k=0k = 0 would make b=1b = 1 rather than a three-digit number. So j=0j = 0, meaning m=2m = 2 and b=a2+a+22.b = \frac{a^2 + a + 2}{2}.

What is left is arithmetic. Requiring bb to have three digits means 100≤a2+a+22≤999100 \leq \tfrac{a^2+a+2}{2} \leq 999, that is 198≤a2+a≤1996198 \leq a^2 + a \leq 1996, which holds exactly for 14≤a≤4414 \leq a \leq 44. Finally we must not forget the first condition, which has not yet been fully used: we need a+1a+1 to divide b−1=a(a+1)2b - 1 = \tfrac{a(a+1)}{2}, and dividing gives a/2a/2, so aa must be even.

The even values of aa from 1414 to 4444 inclusive are 14,16,…,4414, 16, \ldots, 44, and there are 44−142+1=16\tfrac{44-14}{2} + 1 = 16 of them, each giving exactly one bb. So there are 1616 pairs.

Answer 16

Solution: IOQM 2025 Part SEP, Q7

Key idea

Dividing by cc turns the condition into agcd⁡(a,c)+bgcd⁡(b,c)=2627(a+b)\tfrac{a}{\gcd(a,c)} + \tfrac{b}{\gcd(b,c)} = \tfrac{26}{27}(a+b), and since each coefficient is 11 or at most 12\tfrac12, exactly one of the two gcds is 11.

Write g=gcd⁡(a,c)g = \gcd(a,c) and h=gcd⁡(b,c)h = \gcd(b,c), so that lcm⁡(a,c)=ac/g\operatorname{lcm}(a,c) = ac/g and lcm⁡(b,c)=bc/h\operatorname{lcm}(b,c) = bc/h. Dividing the given equation by cc, ag+bh=2627(a+b),that isa(1g−2627)+b(1h−2627)=0.\frac ag + \frac bh = \frac{26}{27}(a+b), \qquad \text{that is} \qquad a\left(\frac1g - \frac{26}{27}\right) + b\left(\frac1h - \frac{26}{27}\right) = 0. The bracket equals 127\tfrac1{27} when the gcd is 11 and is at most 12−2627<0\tfrac12 - \tfrac{26}{27} < 0 otherwise. Two positive brackets cannot sum to zero, nor can two negative ones, so exactly one of g,hg, h is 11.

Say g=1g = 1, and handle the other case by symmetry at the end. Then a27=b(2627−1h),a=26b−27bh.\frac{a}{27} = b\left(\frac{26}{27} - \frac 1h\right), \qquad a = 26b - \frac{27b}{h}. Write b=hsb = hs, which is legitimate because hh divides bb. Then a=26hs−27s=s (26h−27).a = 26hs - 27s = s\,(26h - 27). Since h≥2h \ge 2 we get 26h−27≥2526h - 27 \ge 25, and h≥3h \ge 3 would already give a≥51>50a \ge 51 > 50. So h=2h = 2, b=2sb = 2s and a=25sa = 25s, leaving s∈{1,2}s \in \{1,2\}.

The case s=2s = 2 dies at once: it gives a=50a = 50 and b=4b = 4, and h=gcd⁡(4,c)=2h = \gcd(4,c) = 2 forces cc even, whereupon gcd⁡(50,c)≥2\gcd(50, c) \ge 2, contradicting g=1g = 1.

So s=1s = 1, that is a=25a = 25 and b=2b = 2. The conditions on cc are gcd⁡(2,c)=2 ⇒ c even,gcd⁡(25,c)=1 ⇒ 5∤c.\gcd(2,c) = 2 \ \Rightarrow\ c \text{ even}, \qquad \gcd(25,c) = 1 \ \Rightarrow\ 5 \nmid c. Among 1≤c≤501 \le c \le 50 there are 2525 even numbers, of which the 55 multiples of 1010 are excluded, leaving 2020 values of cc.

By the symmetry that swaps aa with bb, the case h=1h = 1 contributes another 2020 triples, and the two families are disjoint. The total is 20+20=40.20 + 20 = 40.

Answer 40

Solution: IOQM 2025 Part SEP, Q28

Key idea

Writing a=gxa = gx, b=gyb = gy with gg the gcd turns the equation into gxy(g−11)=406+7ggxy(g-11) = 406 + 7g, which forces 12≤g≤3112 \le g \le 31 and then leaves one case.

Put g=gcd⁡(a,b)g = \gcd(a,b) and a=gxa = gx, b=gyb = gy with gcd⁡(x,y)=1\gcd(x,y) = 1, so that lcm⁡(a,b)=gxy\operatorname{lcm}(a,b) = gxy. The equation becomes g2xy=406+11gxy+7g,that isgxy (g−11)=406+7g.g^2xy = 406 + 11gxy + 7g, \qquad \text{that is} \qquad gxy\,(g-11) = 406 + 7g.

The right-hand side is positive, so g≥12g \ge 12. And since xy≥1xy \ge 1, g(g−11)≤406+7g,g2−18g−406≤0,g(g-11) \le 406 + 7g, \qquad g^2 - 18g - 406 \le 0, whose positive root is 9+4879 + \sqrt{487}. Since 232=529>48723^2 = 529 > 487, that root is less than 3232, so g≤31g \le 31.

Now g(g−11)g(g-11) must divide 406+7g406 + 7g. Rather than test twenty values of gg, substitute d=g−11d = g - 11, so that 1≤d≤201 \leq d \leq 20 and the condition reads d(d+11)∣7d+483.d(d+11) \mid 7d + 483. In particular dd divides 7d+4837d + 483, so dd divides 483=3⋅7⋅23483 = 3 \cdot 7 \cdot 23. The divisors of 483483 are 1,3,7,21,23,69,161,4831, 3, 7, 21, 23, 69, 161, 483, and only the first three are at most 2020. So three values of gg survive, and substituting each settles it: dgd(d+11)7d+483divides?11212490no31442504yes, quotient 12718126532no\begin{array}{c|c|c|c|c} d & g & d(d+11) & 7d + 483 & \text{divides?} \\ \hline 1 & 12 & 12 & 490 & \text{no} \\ 3 & 14 & 42 & 504 & \text{yes, quotient } 12 \\ 7 & 18 & 126 & 532 & \text{no} \end{array}

So g=14g = 14 and xy=12xy = 12 with gcd⁡(x,y)=1\gcd(x,y) = 1, leaving {x,y}={1,12}\{x,y\} = \{1,12\} or {3,4}\{3,4\}. Then a+b=g(x+y)=14⋅13=182or14⋅7=98.a + b = g(x+y) = 14 \cdot 13 = 182 \qquad \text{or} \qquad 14 \cdot 7 = 98.

The smallest is 9898, from (a,b)=(42,56)(a,b) = (42,56), which checks out: 42⋅56=2352=406+11⋅168+7⋅1442 \cdot 56 = 2352 = 406 + 11 \cdot 168 + 7 \cdot 14.

Answer 98

Report an error on this page

Reports are stored by Netlify. See the privacy note.