Library · Between the Challenge and the Olympiad · Chapter 2
Divisibility, Primes and Congruences
On this page
- Problems
- Solutions
- Solution: PRMO 2013, Q1
- Solution: PRMO 2014, Q1
- Solution: IOQM 2024, Q1
- Solution: IOQM 2025 Part SEP, Q7
- Solution: IOQM 2025 Part SEP, Q28
- Solution: IOQM 2026, Q2
- Solution: PRMO 2015 Part A, Q4
- Solution: PRMO 2019, Q4
- Solution: PRMO 2019, Q14
- Solution: IOQM 2020, Q6
- Solution: IOQM 2020, Q17
- Solution: IOQM 2021 Part A, Q3
- Solution: IOQM 2023, Q6
- Solution: PRMO 2012, Q11
- Solution: PRMO 2012, Q16
- Solution: PRMO 2013, Q18
- Solution: PRMO 2014, Q11
- Solution: PRMO 2014, Q13
- Solution: PRMO 2015 Part A, Q13
- Solution: PRMO 2018, Q22
- Solution: PRMO 2019, Q21
- Solution: IOQM 2020, Q14
- Solution: IOQM 2020, Q28
- Solution: IOQM 2022, Q7
- Solution: IOQM 2023, Q9
- Solution: IOQM 2024, Q29
- Solution: IOQM 2026, Q25
- Solution: PRMO 2014, Q17
- Solution: PRMO 2014, Q18
- Solution: PRMO 2017, Q28
- Solution: PRMO 2017, Q29
- Solution: PRMO 2018, Q25
- Solution: PRMO 2019, Q12
- Solution: PRMO 2019, Q18
- Solution: PRMO 2019, Q30
- Solution: IOQM 2020, Q25
- Solution: IOQM 2021 Part B, Q2
- Solution: IOQM 2022, Q8
- Solution: IOQM 2022, Q17
- Solution: IOQM 2022, Q18
- Solution: IOQM 2023, Q29
- Solution: IOQM 2023, Q30
- Solution: IOQM 2024, Q18
- Solution: IOQM 2024, Q23
- Solution: IOQM 2024, Q28
- Solution: IOQM 2026, Q29
- Solution: PRMO 2019, Q20
- Solution: IOQM 2020, Q30
Problems
Problem 1
What is the smallest positive integer such that for some positive integers and , with ?
Problem 2
A natural number is such that . What is the largest prime factor of ?
Problem 3
The smallest positive integer that does not divide is:
Problem 4
Find the number of positive integers less than or equal to , which are divisible by but are not divisible by .
Problem 5
Find the number of positive integers less than or equal to 100 such that is not divisible by any prime number other than 2 or 3.
Problem 6
An integer is divisible by but not by . What is the number of distinct possible remainders when is divided by ?
Problem 7
Let be a non-zero polynomial with integer coefficients. If is divisible by for each positive integer , what is the value of ?
Problem 8
An ant leaves the anthill for its morning exercise. It walks feet east and then makes a turn to the right and walks more feet. It then makes another turn to the right and walks 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 such that is a prime and is a perfect square.
Problem 10
What is the least positive integer by which 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 are also considered as factors of .)
Problem 12
Consider the set of all triangles whose sides are distinct prime numbers which are also in arithmetic progression. Let be the triangle with the least perimeter. If is the largest angle of and if is its perimeter, determine the value of .
Problem 13
Let be the set of all even positive integers such that the measure of the angle of some regular polygon is degrees. Find the number of elements in .
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 are divisible by all positive integers such that ?
Problem 16
Let . What is the largest integer that is a divisor of for all positive even integers ?
Problem 17
Let be the set of natural numbers. Suppose is a function satisfying the following conditions.
(a) ;
(b) if ;
(c) .
What is the value of ?
Problem 18
What is the maximum possible value of for which 2013 can be written as a sum of consecutive positive integers?
Problem 19
For natural numbers and , let denote the greatest common divisor of and . How many pairs of natural numbers and with satisfy the equation ?
Problem 20
For how many natural numbers between and (both inclusive) is an integer?
Problem 21
Let be the largest integer that is the product of exactly 3 distinct prime numbers, , and , where and are digits. What is the sum of the digits of ?
Problem 22
A positive integer is said to be good if there exists a partition of into disjoint proper subsets such that the sum of the numbers in each subset of the partition is . How many good numbers are there?
Problem 23
Consider the set . For any partition of , with both and non-empty, consider the number obtained by adding the product of elements of to the product of elements of . Let be the largest prime number among these numbers. Find the sum of the digits of .
Problem 24
The product 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 is said to be good if is the sum of consecutive positive integers, for some . Find the number of good numbers in the set .
Problem 26
Find the number of ordered pairs such that and .
Problem 27
Find the number of triples of positive integers such that
is a prime;
is a product of two primes;
is not divisible by square of any prime and
.
Problem 28
Let . Let denote the number of positive divisors of which are less than but would not divide . What is the number formed by taking the last two digits of (in the same order)?
Problem 29
If where are positive integers, find .
Problem 30
Let be the function defined by for all positive integers . Find the smallest positive integer such that for all positive integers .
Problem 31
Let . What is the largest positive integer that divides all the numbers in ?
Problem 32
For a natural number , let denote the number of natural numbers for which the equation has integer roots. What is the smallest value of for which ?
Problem 33
Let be a one-to-one function from the set of natural numbers to itself such that for all natural numbers and . What is the least possible value of ?
Problem 34
Let be prime numbers such that is a multiple of for all positive integers . Find the least possible value of .
Problem 35
For each positive integer , consider the highest common factor of the two numbers and . For , find the largest value of .
Problem 36
Let be the smallest positive integer which, when divided by leaves remainders in the sets , , respectively. What is the sum of the squares of the digits of ?
Problem 37
A natural number is called good if there exist natural numbers such that Let be the sum of the first good numbers, . Find the sum of all values of for which is an integer.
Problem 38
How many ordered pairs of positive integers with and satisfy ?
Problem 39
Let denote the set of all natural numbers such that and the set can be partitioned into subsets with equal sums. Find the number of elements of .
Problem 40
For a positive integer , let denote the perfect square integer closest to . For example, , . If is the smallest positive integer such that find the sum of the squares of the digits of .
Problem 41
Find all natural numbers for which there exists a permutation of such that Note: A permutation of is a bijective function from to itself.
Problem 42
Suppose the prime numbers and satisfy . Write as , where are positive integers, and . Find the maximum value of .
Problem 43
For a positive integer , let denote the largest positive proper divisor of and . For example, , and , . Let be the smallest positive integer such that . Find the largest integer not exceeding .
Problem 44
Let be natural numbers such that Find the maximum possible value of .
Problem 45
A positive integer is called beautiful if can be written in one and only one way as for some positive integers , where and . (For example is beautiful since , and this is unique. But is not beautiful since as well as , so uniqueness is lost.) Find the largest beautiful number less than 100.
Problem 46
Let denote the number of positive integer divisors of a positive integer . If is the number of integers for which is odd, find the sum of the digits of .
Problem 47
Let be two-digit numbers neither of which are divisible by . Let be the four-digit number by putting the digits of followed by the digits of (in order). As vary, a computer prints on the screen if and divides . Suppose that the largest number that is printed by the computer is . Determine the number formed by the last two digits of (in the same order).
Problem 48
Consider the fourteen numbers, . The smallest natural number such that they leave distinct remainders when divided by is:
Problem 49
Find the largest positive integer such that is not divisible by the square of any prime number.
Problem 50
Find the number of ordered pairs where and are positive integers less than or equal to 20000 such that is a power of 2.
Problem 51
If are positive integers such that find .
Problem 52
Find the number of ordered pairs where and are positive integers such that and the product is a perfect square.
Problem 53
How many natural numbers are there such that ?
Problem 54
Let . Find the remainder when is divided by .
Problem 55
Consider the set of all natural numbers such that when divided by , respectively, the remainders, in that order, are distinct prime numbers in an arithmetic progression. If is the largest number in , find the sum of digits of .
Problem 56
Find the number of pairs of natural numbers such that is a 3-digit number, divides and divides .
Problem 57
Find the number of ordered triples of positive integers such that which satisfy the relation Here, by we mean the LCM, that is, least common multiple of and .
Problem 58
Consider the collection of all ordered pairs of positive integers and which satisfy What is the smallest possible value of ?
Solutions
Solution: PRMO 2013, Q1
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: So works, with and , and no smaller positive integer exists.
The identity 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 into arrives at the same place a moment later.
Answer 1
Solution: PRMO 2014, Q1
Locate the two consecutive squares on either side of ; they determine , after which its prime factors answer the question.
The squares nearest are and , and so and no other natural number will do, the squares being increasing.
Factorising, , so the largest prime factor is .
Answer 11
Solution: IOQM 2024, Q1
Every integer up to is built from the primes , , and , all of which sit inside with room to spare, and the first integer needing a new prime is .
Write in terms of its primes: Any integer whose prime factorisation fits inside this one divides , and the integers through all do: for instance and and are covered comfortably. But is a prime that does not appear in the list at all, so it cannot divide .
Hence the smallest positive integer that does not divide is .
Answer 11
Solution: IOQM 2025 Part SEP, Q7
Count the multiples of and remove those that are also multiples of , that is, the multiples of .
The multiples of up to are , and there are of them. Among these, the ones divisible by are exactly the multiples of , of which there are .
So the count is .
Answer 17
Solution: IOQM 2025 Part SEP, Q28
Such an is exactly a number of the form , so list them by the power of .
A positive integer divisible by no prime other than and is precisely one of the form with , and counts, since it has no prime divisor at all. Listing them by the power of : There are of them.
Answer 20
Solution: IOQM 2026, Q2
Since is itself a multiple of , taking away multiples of cannot spoil divisibility by , so the remainder is a multiple of , and it is not zero.
Write with . Then is a difference of two multiples of , so is a multiple of . And , since would make a multiple of .
So is one of , and every one of these really occurs, because is divisible by and not by . The list runs from to , so there are possible remainders.
Answer 63
Solution: PRMO 2015 Part A, Q4
For integer polynomials always divides , so the hypothesis forces every to divide the single fixed number .
For example, take : is divisible by . 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 and , the difference divides . It follows from applied term by term, and the coefficients being integers is exactly what makes the resulting factorisation an integer one.
Take . Then divides for every positive integer . We are told that also divides , so subtracting, Now is one fixed integer, and no non-zero integer is divisible by every positive integer, since larger than would already be too big. Therefore .
Note that the condition " is non-zero" is there to keep the polynomial itself interesting, not to rescue the argument: is a perfectly good example, and its value at is indeed .
Answer 0
Solution: PRMO 2019, Q4
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.
At each stop the ant turns to the right, so the angle between the leg it arrives on and the leg it leaves on, measured inside the path, is .
Every stop lies on one circle
Call the anthill and the stops in the order the ant reaches them. Draw the circle through , and , and let be its centre. Equal chords of a circle subtend equal angles at the centre, and , so the rotation about that carries to also carries to . 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 . Repeating the argument, one fixed rotation about 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 stands at the circumference on the arc that does not contain , so that arc measures . The rest of the circle, which is , is the arc from to the other way round, through , and it is made of two equal steps. Each leg therefore advances the ant round the circle.
When the ant gets home
After legs the ant has gone degrees round the circle, and it is back at the anthill exactly when that is a whole number of complete laps: Since and share no factor, must divide , so the first return is at and the ant walks feet. Nine steps of come to , which is four laps, so the ant circles the anthill four times before closing up. The nine stops are equally spaced round the circle, apart, and the ant visits every fourth one: that is the nine-pointed star in the figure.
Answer 36
Solution: PRMO 2019, Q14
A square is modulo only for , which thins the candidates to a short list, and then the primality of picks the third of them.
Write with a positive integer. Reducing modulo , The squares modulo are , and happens exactly for
or , since and while the other remainders give or .
So , and grows with . Running through them in order and keeping only : the values giving , which are too small.
Now test the primality of in that order. For we get , not prime. For we get , not prime. For we get , which is prime, since it is divisible by none of , , , and . Also , as required.
The smallest such is .
Answer 53
Solution: IOQM 2020, Q6
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 , and . Since and ,
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 is already even and needs nothing, while the exponents of and of are both odd and each needs one more copy of its prime.
Multiplying by therefore does the job, giving . Nothing smaller can work, because any successful multiplier must supply at least one factor of and at least one factor of , and the smallest positive integer doing both is .
Answer 15
Solution: IOQM 2020, Q17
Having exactly four divisors is a statement about shape, not size: it happens only for and for with and distinct primes.
For a small example, has divisors . We choose the exponent of in three ways and the exponent of in two ways, giving divisors. This is the pattern behind the divisor-count formula.
The number of divisors of is , since a divisor is built by choosing an exponent for each prime independently. For that product to equal there are only two ways to break into factors bigger than one, namely itself and . The first gives a single prime with exponent , so ; the second gives two distinct primes each with exponent , so . 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 has only one digit and has three, the only two-digit cube of a prime is .
For the products of two distinct primes, fix the smaller prime and list the larger one: There is no row with smaller prime or above, since already exceeds two digits. Adding up, the products contribute , and the single cube contributes one more, for a total of .
Answer 30
Solution: IOQM 2021 Part A, Q3
Three distinct primes in arithmetic progression that also form a triangle: the smallest such triple is , and its largest angle is a familiar .
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 , whose common difference is , and they do form a triangle since . 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 must have as its smallest term, since no prime is smaller, so its terms are , , , and the largest of those is even and exceeds , so it is not prime. The least perimeter is therefore .
The largest angle lies opposite the longest side, . By the cosine rule, so and . The clean value of the cosine is a sign that this triple was chosen deliberately.
Therefore .
Answer 8
Solution: IOQM 2023, Q6
The interior angle of a regular -gon is , so asking for an even integer angle is asking for an even divisor of that leaves at least three sides.
A regular polygon with sides has interior angle Write . For to be an integer, must be an integer, that is must divide , and then is itself a divisor of ; and since is even, is even exactly when is even. The constraint becomes , and is then automatic.
So the task is to count the even divisors of that are at most . Since has divisors, of which the odd ones are the divisors of , there are even divisors. Exactly two of them exceed , namely and . That leaves admissible values of , and distinct values of give distinct angles .
A remark on the wording, since it worries people. If "the angle of a regular polygon" were read as the exterior angle instead, the count would be of even divisors of that are at most once more, and the answer would be the same . The ambiguity is harmless.
Answer 16
Solution: IOQM 2025 Part SEP, Q28
The four largest primes below happen to sum to exactly , so there is no freedom at all.
A sum as large as from four numbers none above needs every one of them near the top, so look at the largest primes not exceeding : they are , and exactly. Any other choice of four distinct primes below replaces one of these by a smaller prime and gives a total below .
So the four primes are forced, and the smallest is .
Answer 53
Solution: IOQM 2025 Part SEP, Q28
The set of required divisors changes only at the cubes , and , so split the range at those points and count multiples of , , and .
The condition involves every with , and that set of grows only when passes a cube. The counts in the last column are the multiples in each range: gives ten numbers; gives six; and gives three.
The total is .
Answer 26
Solution: PRMO 2012, Q11
Five consecutive odd factors always include a multiple of and one of . Comparing several sample products then shows whether any further factor is forced.
At the factors are . They visibly supply both and , 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 the five factors are five consecutive odd numbers.
Among any three consecutive odd numbers the remainders modulo run through all three possibilities, so one of them is a multiple of . Among any five consecutive odd numbers the remainders modulo likewise run through all five, so one is a multiple of . Hence divides 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 and : The first is and the second is , whose greatest common divisor is . Bringing in kills the , and , leaving .
So the answer is
Answer 15
Solution: PRMO 2012, Q16
The rule fixes on the powers of two, and the fact that increases squeezes every value in between, so throughout.
First , and the only natural number equal to its own square is , since the natural numbers here start at . So , and gives , , , and in general .
Now squeeze. Between and there is room for exactly one value, and is strictly increasing, so . Between and there are three integers and three values to place, so , , . The same argument between and , where seven values must fill seven places, gives for , and once more between and for up to .
So is the identity on the range we need, and
The three conditions are exactly enough: drop the increasing condition and any rearrangement of the odd primes would do, drop and would do.
Answer 210
Solution: PRMO 2013, Q18
consecutive integers from sum to , so and is a divisor of small enough to leave .
Writing the run as with , So divides .
The requirement caps :
The divisors of at most are , and the largest is . It works: , so and . Indeed
So the maximum is .
Answer 61
Solution: PRMO 2014, Q11
Writing and with turns the equation into , and leaves almost nothing.
Put and , with and . The equation becomes
In particular divides , so , that is With and that leaves with any , or .
: the condition is , so and . For , gives ; for , gives .
: then , so and .
All three check out: , and . So there are pairs.
Answer 3
Solution: PRMO 2014, Q13
Substituting turns the fraction into , so must be a divisor of lying in a narrow window.
Put , so that and The expression is an integer exactly when divides .
Now use the range. As runs from to , the number runs from down to . Writing , the bounds on become bounds on : so is or . Of these only divides , since is not a multiple of . That gives and indeed .
So exactly value of works.
Answer 1
Solution: PRMO 2015 Part A, Q13
The digits and must themselves be primes, so only four choices remain for each. List the pairs for which is prime, then compare their products.
We need with , and three distinct primes, and , single digits. A single-digit prime is one of , which cuts the search down to sixteen pairs before any thought at all.
So run through the four values of , and for each list which of the four numbers is prime. With , for instance, the candidates are , , and , and only is prime. Every value of turns out to leave exactly one choice of : In each row the three primes are distinct, as required.
The largest is , and the sum of its digits is .
Answer 12
Solution: PRMO 2018, Q22
Each subset sums to , so divides the total ; and the part holding forces , while “proper” rules out . Six divisors survive, and each is achievable.
The whole set sums to . If the parts each sum to then divides .
Two more constraints trim the list. The part containing has sum at least , so . And the subsets must be proper, so there is more than one of them, which rules out .
The divisors of lying in are six of them. Each is genuinely achievable, and here is a splitting for each:
: the ten pairs .
: , , , , , , .
: , , , , , .
: , , , , .
: , , and everything else.
: and .
So there are good numbers.
Answer 6
Solution: PRMO 2019, Q21
The sum is odd only when one of the two products is odd, so one part must sit inside and the other must swallow both and , which leaves seven cases instead of fifteen.
A prime larger than is odd, and the two products here are both at least , 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 and the other contains both and .
That leaves seven splittings, and each is one multiplication:
Four of the composites are caught by the digit-sum test for , and the two larger ones need a moment: and . As for , it is prime because it is divisible by none of , and already exceeds it.
So the only prime among these numbers is , which is therefore also the largest, and its digits sum to .
Answer 17
Solution: IOQM 2020, Q14
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:
Now suppose, aiming for a contradiction, that all five integers could be kept at or below. The prime has to divide one of them, and the only multiple of that does not exceed is itself, so one of the five is exactly ; the same reasoning with pins down a second. Dividing them out leaves three distinct integers whose product is
Those three must carry between them, and none of them can be divisible by , since already exceeds . Each of the three is therefore divisible by exactly once, which forces all three to be drawn from , and , the only multiples of below that are not multiples of . Their product is , not , and the contradiction is complete.
So the largest integer must be at least , and is attainable: with all five factors distinct. The least possible value of the largest is .
Answer 20
Solution: IOQM 2020, Q28
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 , , , , and , but , , and resist every attempt. The numbers that resist are the powers of two, and the algebra explains why.
Suppose is the sum of consecutive positive integers starting at , with . Summing the progression, so that . 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 is.
Look at the two factors on the right. Their sum is , which is odd, so exactly one of and is even and the other is odd. Since and , both factors are at least . So has been written as a product of an even number and an odd number greater than one, which means itself has an odd divisor greater than .
Conversely, suppose is not a power of two, and write Since is odd and is even the two are never equal, so exactly one of the following two constructions applies.
If , take the consecutive integers centred at , namely There are of them and their average is , so they sum to . They are positive because is odd and less than , so and the first term is at least . And , so there are at least two terms.
If , take instead the consecutive integers starting at which is a whole number because is odd, and is positive because . Their sum is and the two brackets add to , leaving .
So the numbers that are not good are exactly those with no odd divisor beyond , which is to say the powers of two.
In the range from to the powers of two are , seven numbers in all. Every other number in the range is good, so the count is .
Answer 93
Solution: IOQM 2022, Q7
Strip out the common factor. The condition collapses to , which says that one of the two numbers divides the other.
Write and , with , so that . The condition becomes Dividing by and rearranging, , that is
So or , which means or . The whole gcd-and-lcm dressing was hiding a divisibility condition.
Now count ordered pairs from . The pairs with number , one for each value. For the strictly ordered ones, list the pairs with : since and , the quotient can only be or , giving which is pairs, and each contributes two ordered pairs.
The total is .
Answer 35
Solution: IOQM 2023, Q9
Condition (a) forces one of and to be , and the two resulting cases are short enough to finish by listing primes with product at most .
A prime has exactly two positive divisors, so if is prime then one of equals and the other is that prime. Condition (c) says is squarefree, so all the primes appearing below are distinct. Take the two cases in turn.
Case , prime. Then , and condition (b) says is a product of two primes, say . Squarefreeness makes , , three distinct primes, and (d) requires . The smallest product of three distinct primes is , so that is the only possibility, and the three triples are obtained by choosing which prime plays the role of : That is triples.
Case , prime. Then must be a product of two primes, which forces to be a prime , distinct from by squarefreeness. Condition (d) reads . The unordered pairs of distinct primes with product at most are seven in all, since and already exceed . Here and play different roles, so each pair gives two triples, making .
The cases cannot overlap, since would make , which is not prime. The total is .
Answer 17
Solution: IOQM 2024, Q29
Divisors of pair off as and around , so exactly half of the ones other than are smaller than ; subtract the divisors of that are smaller than .
With we have , so
The divisors of come in pairs , and the two members are equal only for . Of the remaining divisors, exactly one of each pair is less than , so
Among these, the ones that do divide are precisely the divisors of other than itself, of which there are . Hence and the last two digits are .
Answer 28
Solution: IOQM 2025 Part SEP, Q28
Writing for the continued fraction on the left, the expression is , and is the same continued fraction with its first term reduced by one.
Let so the left-hand side is . Turning that upside down, since .
Now read off the terms. Comparing with the required shape, , and what remains is because subtracting from only changes its leading term from to . So and then the rest is read straight off: (This is the unique such expansion, since at each stage the integer part is forced.)
The sum is .
Answer 27
Solution: IOQM 2025 Part SEP, Q7
The base repeats with period and the exponent matters only modulo , so is a period; the work is showing that nothing smaller is.
For not divisible by , Fermat’s little theorem gives . So and when both sides are . Hence is a period. The least positive period divides it: if with , then for every positive , so a positive would contradict the minimality of . Thus .
One observation cuts the divisors down: must divide the period: if it did not, then some multiple of would be sent to a non-multiple of , turning a value of into a non-zero one. That leaves , , and .
Now test the three small ones against actual values, using : Since the powers of cycle as modulo , which is not , so fails. Likewise so fails. For , use and where leave remainders , and , so .
Everything smaller having failed, the least period is .
Answer 42
Solution: IOQM 2026, Q25
The expression factorises as . The first factor is always a multiple of and the second a multiple of , and two small primes show that nothing larger divides every member.
Factorise: . The prime is odd and is not a multiple of .
The first factor is , two consecutive even numbers, one of them a multiple of , so divides it. One of , , is a multiple of , and it is not , so divides it too, and divides . Since divides , the second factor is a multiple of . So every member of is a multiple of .
Nothing larger works. With the member is , and with it is . A number dividing both divides . The answer is .
Answer 72
Solution: PRMO 2014, Q17
The roots are a factor pair of , so is the number of unordered factorisations, and means has or divisors.
If has integer roots then, since their sum is and their product is , both roots are negative: write them as and with and .
Different factor pairs give different values of , because a pair is recovered from its sum and product. So is the number of unordered pairs with , which is where counts the divisors: the divisors pair up as with , with a middle divisor left over exactly when is a perfect square.
So means or , and we want the smallest such .
Write with the exponents in decreasing order. Then , so a value of fixes the exponents up to a factorisation of that value into factors greater than one. For a given list of exponents the smallest puts the largest exponent on the smallest prime and uses the smallest primes available: swapping a larger exponent from a prime onto a smaller prime carrying divides by , and replacing any prime by a smaller unused one shrinks as well.
That leaves a finite list to inspect. For the seven factorisations and the smallest number each allows are together with the single exponent , giving . For the only factorisations are itself and , giving and .
The smallest entry anywhere in those two lists is and indeed , giving .
Answer 1680
Solution: PRMO 2014, Q18
, and injectivity forces and to be different values at least , so the minimum is .
Since and is multiplicative,
Two constraints. First , and the only natural number equal to its own square is , since the natural numbers here start at . So , and injectivity then forbids any other value from being : in particular and . Second , again by injectivity.
So we are minimising over distinct integers , which is smallest at , :
That bound is attained. Send the prime to , the prime to , 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 is one-to-one and multiplicative, and .
Answer 24
Solution: PRMO 2017, Q28
The condition on turns out to be two clean statements: is squarefree, and divides for each prime factor . For that reduces to and , which leaves a short search.
A condition that holds for every can be tested one prime factor at a time. Write for the modulus while we find the general rule. For a small warning about repeated prime factors, try and : has only one factor of , so it is not divisible by . This suggests starting with squarefreeness.
The criterion
Suppose for every . Then is squarefree: if then taking gives , so , which is false.
Next, for each prime we show . Take any not divisible by . From we get , and Fermat’s little theorem gives as well. So two different exponents send to , and the first thing to notice is that their gcd does too.
Indeed, if and with , then as well, since multiplying by gives . The exponents that send to 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 and , so it divides their gcd , and hence for every one of the non-zero remainders .
That is a great many solutions of one equation. The next step is to say that an equation of degree cannot have so many.
How many roots an equation can have modulo a prime
Over the ordinary numbers a polynomial of degree has at most roots, and the reason is the factor theorem: a root lets one write with of degree one less. The same proof works modulo a prime , and that is the only property of primes it uses.
Dividing by leaves , so a root gives . If is another root then with , and modulo a prime a product vanishes only when one factor does, so . Every root therefore peels off a factor and drops the degree by one, and there can be at most of them.
Apply this to . All non-zero remainders are roots of it, so . But divides , so and therefore .
The criterion, the other way round
Conversely, if is squarefree and for every prime , then each such divides : when both terms are multiples of , and otherwise by Fermat’s little theorem. Being squarefree, divides .
Applying it to
Squarefreeness needs , , distinct. From we need , so is odd and neither nor is . From , reduce modulo : since , and symmetrically .
The search
Take , both odd primes other than . From we get , so the search is finite.
: gives , none an allowed prime.
: allows , but then must divide , and it does not.
: gives , and is prime. Check the other condition: divides . It works.
: would have to divide , which is never a multiple of . Impossible.
Any remaining pair has and hence . So the least value is
The two conditions established at the start, squarefree and , are Korselt’s criterion. The number 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
Any common factor is coprime to , so it divides ; and Wilson’s theorem says divides exactly when is prime.
Let .
First, is coprime to , because a common factor of and would divide both and , hence divide . Since , it follows that
So is at most . When is prime, Wilson’s theorem shows that divides , and here is the proof of the case we need.
Modulo a prime , every non-zero remainder has a unique multiplicative inverse: multiplication by that remainder permutes the non-zero remainders. The only remainders that are their own inverses are and , since and a prime dividing that product divides one factor. Pair all the others with their inverses. For example, modulo the pair has product , leaving and . Every inverse pair has product , so For this holds directly as well. Thus and in the prime case.
If is composite, every prime factor of is at most and so divides ; but is coprime to , so . Hence
For we want the largest prime of the form with , that is the largest prime at most . That is , from .
Answer 97
Solution: PRMO 2018, Q25
The three remainder sets have only nine combinations that survive the moduli and , and one of the nine already meets the condition modulo at its very first value.
We need a whose remainders satisfy , and , and .
Start with the last two conditions, which fix modulo . The numbers below with remainder on division by are , and each step of raises the remainder modulo by , so their remainders modulo run The ones in sit at , and . The same walk from and from finds three more each, and , so nine possibilities in all:
Now test the smallest representative of each against the condition modulo . The first eight values in increasing order are , whose remainders modulo are Only the last lies in . The ninth candidate, , has remainder 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 , which puts it past .
So , and one checks directly: , , . The sum of the squares of its digits is
Answer 81
Solution: PRMO 2019, Q12
Every is good: express as a sum of distinct unit fractions and square their denominators to obtain the . The case fails, and the remaining good numbers form a simple arithmetic progression.
Which are good
Suppose first that , so with . Then , so , and is impossible since it already exhausts the sum. That leaves two cases, and both fail: and neither value of is an integer, and being irrational. So is not good.
Every is good, and the construction is short. Write as a sum of distinct unit fractions , then take , so that and the are distinct. Such a decomposition exists for every : start from and to go from parts to split the smallest part using , which replaces one denominator by two strictly larger ones and so keeps every denominator distinct.
The good numbers are therefore exactly
The sum and the ratio
The first good numbers are , so Hence the factor cancelling, which is the reason the problem shifted by exactly five. This is an integer precisely when divides , that is , and
Answer 18
Solution: PRMO 2019, Q18
Writing and with turns the condition into , and has only four coprime splittings, after which the range counts the multipliers.
Let and write , with . Then , so the ratio condition says
Now . A coprime splitting must give each prime power entirely to one side, so there are ordered pairs and, imposing to match , exactly four:
For each, the constraints are and , since makes the other two inequalities automatic.
: needs and , impossible.
: needs and , impossible.
: needs , so , and , so . That is values.
: needs , so , and , so . That is values.
The two impossible cases are impossible for the same reason: a lopsided splitting forces to be hundreds of times , and the window from to is only ten-fold. Adding the rest, ordered pairs.
Answer 20
Solution: PRMO 2019, Q30
The total must be divisible by , which happens exactly when or ; and every such from upwards really can be split, by four base cases and a jump of six.
The necessary condition
If splits into three subsets of equal sum, then divides . Checking the three remainders of modulo , one finds is a multiple of exactly when since makes both and prime to .
The construction
Four base cases, each an explicit split into three parts of equal sum: And one step: given a valid split of , the six new numbers form three pairs of equal sum , namely so handing one pair to each subset splits . Since the four base cases cover the remainders modulo , and those are exactly the remainders allowed by the divisibility condition, every satisfying it can be split.
The smallest cases are genuinely excluded and not merely awkward: for the total is , which is not divisible by at all, and in general must be at most a third of the total, which fails below .
The count
So consists of the with and or , together with the requirement , which excludes nothing further since already fails the divisibility. Counting from to : Hence .
Answer 64
Solution: IOQM 2020, Q25
The four given numbers each sit just beside a square, and once their nearest squares are found the equation reduces to a single ratio, , which forces into the family .
Begin by evaluating the four bracketed terms, each time comparing the distances to the squares on either side. For the neighbours are and , at distances and , so . For the neighbours are and , at distances and , so . Similarly , being one below , while sits between and at distances and , so .
The equation now reads and rather than multiply everything out it is far easier to cancel prime by prime. Since and , the right side carries , which cancels against ; one factor of cancels against ; and the remaining leaves
So , which tells us two things at once. First, must divide , say , whence . Second, has to be a perfect square, and since is square-free this forces . Putting these together,
It remains to check that really is the nearest square to , since we derived the form from an equation, while the bracket has a meaning of its own, the nearest square. Taking the smallest case , we have lying between and , at distances and respectively, so the nearest square is indeed . The smallest positive is therefore , and the sum of the squares of its digits is .
Answer 56
Solution: IOQM 2021 Part B, Q2
Modulo the alternating weights all collapse to , so the sum is congruent to ; that rules out , and a three-step induction builds the rest.
Which are impossible
Since , every power is congruent to , so for any permutation , The right-hand side is a multiple of unless , in which case it is . So for the sum can never be zero, whatever the permutation.
Which work
Every other does work, by induction in steps of three.
The two smallest cases are explicit. For take , giving . For take , giving .
To extend a working list, shift its entries up by and move it two positions to the right. Its old zero sum stays zero, multiplied by , but the added s contribute a geometric sum. The unused values can cancel that correction: put first and last. For example, extends to , whose weighted sum is .
Now suppose a permutation of works. The same arrangement for is: This is a permutation of : the values , , are used once each and the rest are shifted up by .
Its sum splits into the shifted copy of the old sum and a correction. The shifted copy contributes and the geometric series evaluates as Adding the three special terms ,
So from and the construction reaches every larger congruent to or modulo , and the answer is
Answer proof
Solution: IOQM 2022, Q8
Rearrange to . Since is prime and cannot equal , it must divide , and writing turns the problem into a single divisibility in .
Move everything to expose the factorisations: The prime divides the right side, so it divides , hence or . The case gives , so , which has no prime solution.
So write with a positive integer. Substituting , and gathering the terms in gives .
Since and are positive, we need , so , and must be a prime. For the denominator is at least while the numerator is at most , so would be less than . That leaves only : which is prime. Then , also prime.
Finally , so , , , and .
Answer 32
Solution: IOQM 2022, Q17
The largest proper divisor of is where is the smallest prime factor, so . Running that backwards from branches only a little, and the smallest survivor is a prime.
If is the smallest prime factor of , then the largest proper divisor is , so In particular for even , and for odd the factor has an odd denominator. Rather than search forwards we invert the map three times, starting from .
Solving
If is even then and . If is odd with least prime , then , and since is coprime to we need , so , which is not odd, or , which is not prime. So uniquely.
Solving
Even gives . Odd needs , so , of which only is an odd prime, giving , whose least prime really is . So .
Solving or
From : even gives ; odd needs , so . Here would give the even number , a contradiction; gives , valid; and gives , a prime, for which , also valid. From : even gives , and odd needs , which offers no odd prime.
The candidates are , , and , so the smallest is . Since and , the largest integer not exceeding is .
Answer 19
Solution: IOQM 2022, Q18
Factor out the gcd. The equation becomes , so is or , and each case is a small factorisation.
Write with and , where , so that . The equation becomes that is, Since is a positive integer dividing , either or , and the bracket takes the complementary value.
The case , which is where the maximum lives
Here , so . Multiplying by to make it factor, , and adding to both sides, As is prime, the positive possibilities are or . The first gives , , which fails because . The second gives , , which is coprime, so and , and .
The case
Now , and the same manipulation gives . Here is positive, so is too, and the four factorisations of give The first three share a factor, so only , is coprime, giving , and .
The larger of the two is .
Answer 70
Solution: IOQM 2023, Q29
Ones may be padded on freely, so a representation is really a factorisation of into factors at least ; uniqueness therefore says is a product of exactly two primes.
Suppose . The factors equal to do not affect the product, and each adds to the sum, so a representation is completely described by the factors that exceed , listed with repeats and in no particular order: if those are with product and sum , the number of ones is forced to be .
That number of ones is never negative. For factors each at least , which for two factors is and follows for more factors by repeating the step. So every factorisation of into two or more factors, each at least , gives exactly one valid representation, and every representation arises this way.
Uniqueness therefore means: has exactly one factorisation into two or more factors greater than . A prime has none at all, so primes are not beautiful. If has three prime factors counted with multiplicity, say , then and are two different factorisations, so is not beautiful; and the same applies with more factors. That leaves exactly the numbers with two prime factors counted with multiplicity, , whose only factorisation is .
So the beautiful numbers are the products of two primes. Checking downwards from : has three prime factors, has three, is prime, has many, and is a product of two primes. The largest beautiful number below is .
The example in the problem is worth revisiting with this in hand: has the two factorisations and , which are exactly the two representations displayed there.
Answer 95
Solution: IOQM 2023, Q30
is odd only for perfect squares, so the running total is odd exactly when is odd.
The first few divisor counts and running sums show where the parity changes: The running sum changes parity at , the squares. Divisor pairing explains that pattern.
Divisors come in pairs and , and the two coincide only when is a perfect square. So is odd exactly when is a perfect square, and therefore The sum is odd exactly when is odd.
Now count such . The integers with are those from to , and there are of them. Since , the value of runs from to , and the largest odd is , whose block ends at , comfortably inside the range. So no block with odd is cut short, and There are odd values of , and their sum is , so
The sum of the digits of is .
Answer 18
Solution: IOQM 2024, Q18
Since and shares no factor with , the condition says exactly that divides .
Write . Then so divides exactly when divides . Now , so
this happens exactly when
The divisors of are . Both and are two-digit, so , leaving only and .
To make large we want as large as possible, and allows a much larger than does, where and hence . So take and work downward from the largest admissible , remembering that must be two-digit and not a multiple of , and that : So the largest printed number is , and a check confirms .
The last two digits are .
Answer 13
Solution: IOQM 2024, Q23
Modulo the fourth powers of and agree, so most small fail immediately; works because the only fourth roots of unity modulo are .
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 actually are. We are trying to manufacture two different numbers in the range to that are forced to share a fourth power, because one such pair kills that value of outright.
The cheapest manufacturer is , so any for which two of add up to is ruled out at once. For take the pair and , which are distinct and both in range. That disposes of everything from to , and is impossible because fourteen numbers cannot have fourteen distinct remainders modulo or less, while falls to the pair and .
Three cases remain below .
: , and , so and collide.
: here , so . Hence , , and all share a fourth power, and for these four are distinct, since , , and are distinct modulo . The non-zero remainders therefore fall into seven groups of four, leaving only seven possible fourth powers, which cannot accommodate fourteen numbers.
: , so and collide.
Now take , and suppose . Then , and modulo a prime forces , so . The minus sign is impossible, because it would give contradicting Fermat’s little theorem. So and . To finish without dividing remainders, suppose for . Then The prime divides neither nor , since and . It must therefore divide , giving . Raising to the fifteenth power gives , but Fermat’s theorem makes these two sides and . This contradiction shows that no two such fourth powers coincide. So the fourteen fourth powers are distinct modulo , and is the smallest such .
Answer 31
Solution: IOQM 2024, Q28
The expression factors as over , and for every from to some small prime, usually or , appears twice among those factors.
First factorise. Treating it as a quadratic in , and each part factors further: , while completing a square gives So
For the whole thing to be squarefree, no odd prime may divide two factors or occur twice in one factor. For , the division by removes one copy, so we must count its copies before cancelling. Two obstructions recur.
The prime : for odd , both and are even and is even as well, so divides the product and a single division by cannot rescue it. That rules out every odd at a stroke, in particular .
That leaves the four even values , and each falls to a single visible square:
Now test : after cancelling the , and every prime here, namely , occurs once. So the value is squarefree and the answer is
Answer 20
Solution: IOQM 2025 Part SEP, Q28
Writing , the equation forces , because two squares summing to a power of two must be equal.
Set , so the condition is for some .
Suppose and are both odd. Then , so their sum is , which is a power of two only if the sum is itself, giving . If one is odd and the other even, the sum is odd and larger than , which is impossible. So they are both even, and dividing the equation by returns the same problem for and .
Descending in this way, we reach the odd case, so for some . Since , that means , so is even, and writing gives
Finally the bounds. We need , and while , so runs from to ; the condition on is then automatic. That is ordered pairs.
Answer 8
Solution: IOQM 2025 Part SEP, Q28
The two sides of the equation are the numerator and denominator of the continued fraction , so the equation says that this equals .
The two brackets are linked by repeated quotient and remainder. Write , and . Then Dividing the first equation by , then using the other two to read , gives a sequence of reciprocals. This is why a continued fraction is useful. Build it from the inside: The numerator and denominator on the right are exactly the two brackets in the problem, so the given equation says
Now expand as a continued fraction, which is just repeated division: So , , , , and this is the only expansion with four positive integer terms, since at each stage the integer part is forced.
Hence
Answer 31
Solution: IOQM 2025 Part SEP, Q28
is a square exactly when and have the same squarefree part, so group the numbers by that and count pairs inside each group.
Write each integer as with squarefree; the number is its squarefree part. Then is a perfect square precisely when and have the same squarefree part, because and is a square only when , both being squarefree.
So sort into classes by squarefree part. A class with squarefree part consists of the numbers up to , and only can give a class with more than one member: Every other class is a single number and contributes nothing.
Adding up, the number of pairs with is
Answer 44
Solution: IOQM 2025 Part SEP, Q28
Modulo the powers of repeat every steps and the squares every , so the whole condition repeats every , and is exactly five such blocks.
Modulo we have , so depends only on modulo ; and depends only on modulo . So whether depends only on modulo , and since , it is enough to count the good remainders in one block of and multiply by .
The two tables are short. The powers cycle as and the squares are Each value , , that can take is a square for exactly two remainders modulo , so for each remainder of modulo there are two good remainders modulo : A remainder modulo and one modulo cannot belong to two different numbers in one block of : their difference would be divisible by both and , hence by . The six numbers listed below realise all six allowed combinations, so the good remainders number . In they are For instance gives and , while gives but .
Hence the count up to is .
Answer 30
Solution: IOQM 2026, Q29
Here , so leaves remainder on division by . Everything then turns on whether divides , and it does.
Since , the definition says , so leaves remainder on division by . Every power then leaves remainder as well, being a product of numbers each one more than a multiple of .
Now look at : The fraction is a whole number, since is a multiple of , so is even. It is also a multiple of . Since , the power leaves remainder on division by , so divides , and as shares no factor with it divides .
So divides . Writing , the number leaves remainder on division by .
Answer 1
Solution: PRMO 2019, Q20
The three congruence conditions describe remainder classes modulo , and a remainder class contains arbitrarily large numbers, so the set 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 , , on division by , , , so , and . They are to be distinct primes forming an arithmetic progression in that order, so . The primes available are for and for the other two. The prime cannot appear: as or it would make odd, and as it would need from two distinct primes. With odd primes only, would need from distinct primes, which is impossible; needs , giving and in either order; needs , and puts the first; needs , which no two allowed primes reach. That leaves exactly three triples:
Each triple has a representative, checked directly: Any two numbers giving the same triple have a difference divisible by , and , hence by their product , since the three moduli are pairwise coprime. Thus the three possibilities are
And here the question breaks. The set is the union of three remainder classes modulo , each of which is infinite: if lies in then so do , and every further step. So has no largest element, and the phrase “the largest number in ” does not refer to anything.
The intended reading was surely one full cycle, that is the largest below , which is and has digit sum . It is worth writing that out because the working above is a perfectly good exercise in the Chinese remainder theorem. But an answer of needs a hypothesis the paper never states, and the discounting was correct.
Answer none
Solution: IOQM 2020, Q30
Reducing modulo leaves a remainder of , and chasing that through the divisibility forces 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 divides , write . Since divides , write for some positive integer . The useful observation is that while by construction. Reducing modulo therefore gives , so for some integer .
Now show that has to be zero. Substituting both expressions into and expanding, whose right-hand side expands to and cancelling the from each side and then dividing through by leaves If and then the single term already exceeds , which is impossible, and would make rather than a three-digit number. So , meaning and
What is left is arithmetic. Requiring to have three digits means , that is , which holds exactly for . Finally we must not forget the first condition, which has not yet been fully used: we need to divide , and dividing gives , so must be even.
The even values of from to inclusive are , and there are of them, each giving exactly one . So there are pairs.
Answer 16
Solution: IOQM 2025 Part SEP, Q7
Dividing by turns the condition into , and since each coefficient is or at most , exactly one of the two gcds is .
Write and , so that and . Dividing the given equation by , The bracket equals when the gcd is and is at most otherwise. Two positive brackets cannot sum to zero, nor can two negative ones, so exactly one of is .
Say , and handle the other case by symmetry at the end. Then Write , which is legitimate because divides . Then Since we get , and would already give . So , and , leaving .
The case dies at once: it gives and , and forces even, whereupon , contradicting .
So , that is and . The conditions on are Among there are even numbers, of which the multiples of are excluded, leaving values of .
By the symmetry that swaps with , the case contributes another triples, and the two families are disjoint. The total is
Answer 40
Solution: IOQM 2025 Part SEP, Q28
Writing , with the gcd turns the equation into , which forces and then leaves one case.
Put and , with , so that . The equation becomes
The right-hand side is positive, so . And since , whose positive root is . Since , that root is less than , so .
Now must divide . Rather than test twenty values of , substitute , so that and the condition reads In particular divides , so divides . The divisors of are , and only the first three are at most . So three values of survive, and substituting each settles it:
So and with , leaving or . Then
The smallest is , from , which checks out: .
Answer 98