I came across this interesting problem in the Olympiad Maths challenge practice problem, and it is really fascinating:

Some $n$ numbers are selected randomly from the integers $1$ to $420$. $2$ integers $a$ and $b$ are chosen from that set of $n$ numbers such that $a$ and $b$ are relatively prime. Find the minimum value of $n$ that ensures there exists $2$ such integers $a$ and $b$

If you don't know what relatively prime is it means that the two numbers don't share any factors greater than one (therefore the HCF of $a$ and $b$ is $1$)

My evaluation is that two numbers is relatively prime if at least $1$ of the number is prime, therefore not sharing any factors with the other number except $1$ (since primes have the factors only $1$ and itself).

This evaluation should work! UNLESS the second number is the prime number doubled, or tripled, or quadrupled, etc.

First of all, I have to deal with the fact that we're randomly picking from the set of $1$ to $420$, so I have to find the number of prime numbers between $1$ and $420$.

This post almost answers my prime question, but I tried $\pi(420) $ and I got about $69$ (Very nice coincidence by the way, $69420$). And the pool of answers is no near that (Multiple choice: $208, 211, 215, 220$) So I am now stuck in this hole precisely here.

Any help would be greatly appreciated!


1 Answer 1


This can be easily solved by using the pigeon hole principle.

Observe that if two numbers are consecutive, then they are relatively primes. Now one can pick every second number starting from $2$ till $420$ (all the even numbers). Now as every alternate number is picked already, the pigeonhole principle guarantees that picking any more numbers would result in a pair of consecutive numbers, which will be relatively prime.

$\therefore $ The minimum value of $n$ to guarantee that there will be $2$ relatively prime numbers in the chosen $n$ numbers is $211$.

Note: It is not necessary that one of the numbers is prime for the pair to be relatively prime. For example $(9,14)$ is such a pair of relatively prime numbers with none of them being prime. Any numbers of the form $a=p_1^{a_1}\cdot p_2^{a_2}\cdots p_n^{a_n}$ and $b=q_1^{b_1}\cdot q_2^{b_2}\cdots q_m^{b_m}$ are relatively prime $(p_i\neq q_i\space \forall\ i\in \mathbb N)$ with none of them being primes.

  • $\begingroup$ @Chrystomath It asks for the minimum value of $n$ to 'guarantee' the existance of two relatively prime number. If it had not been for the 'guarantee' condition, one could've easily found any two primes among $1$ to $420$ and given the value $n=2$, which makes the question completely useless. $\endgroup$ Commented Feb 26, 2021 at 10:22
  • 1
    $\begingroup$ I’m not convinced by your answer. Your just proved that $n=211$ is a sufficient value that we can find a and b. But you don’t know whether an $m<n$ exists or not and also satisfies that we can find a and b $\endgroup$
    – NN2
    Commented Feb 26, 2021 at 10:27
  • $\begingroup$ @Chrystomath Take the numbers ${2,4,6,8,\cdots, 22}$, and find any pair of co prime numbers in them. $\endgroup$ Commented Feb 26, 2021 at 10:29
  • 3
    $\begingroup$ @NN2 for any $n<211$, I can take the numbers $\{2,4,6,8,\cdots, 2(n-1),2n\}$ and no two of them will be relatively prime. Once $n>211$, at least two of them will be consecutive, hence co prime. Thus the minimum $n$ is $211$, this is the whole premise of pigeonhole principle $\endgroup$ Commented Feb 26, 2021 at 10:32
  • $\begingroup$ Ok, I see now. Thanks $\endgroup$
    – NN2
    Commented Feb 26, 2021 at 11:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .