TITLE: Least (and largest) possible number of non-relatively prime pairs among consecutive integers
QUESTION [5 upvotes]: Given a set of positive integers consider the graph whose vertices are those integers, two of which are joined by an edge if and only if they have a common divisor greater than 1 (i.e, they are not relatively prime). 
What is the least (and most) number of edges such a graph of a set of n consecutive integers can have?
Related question: Graphs determined by sets of consecutive integers

REPLY [3 votes]: This does not quite answer the question (and in fact I doubt a satisfactory answer can be given at all, see below), but hopefully sheds some light on the problem.
Let the consecutive integers under consideration be $a+1,\dotsc,a+n$. I prefer to think in terms of the number of pairs $(a+i,a+j)$ with $1\le i\ne j\le n$ such that $\gcd(a+i,a+j)=1$; denoting this number by $\sigma_n(a)$, the number of edges of the graph in question is $\frac12\,(n(n-1)-\sigma_n(a))$. 
Since $\gcd(a+i,a+j)=\gcd(a+i,j-i)$, the quantity $\sigma_n(a)$ is periodic in $a$ with the period at most $\mathrm{lcm}(1,2,\dotsc,n-1)$. This allows one to compute the largest and the smallest possible values of $\sigma_n(a)$ in a finite number of steps, for any given $n$. Computations show that for $n=2,\dotsc,10$, the smallest possible values of $\sigma_n(a)$ are
  $$ 2,4,8,12,20,24,34,42,56, $$
while the largest possible values are 
  $$ 2,6,10,18,22,34,42,56,64. $$
None of these sequences is in the OEIS. I suspect that no explicit, closed-form expression can be given, but it is not difficult to find an expression that allows one to easily compute $\sigma_n(a)$ and establish its asymptotic behavior. Specifically, in view of $\gcd(a+i,a+j)=\gcd(a+i,j-i)<n$ for any $i,j\in[1,n]$ with $i\ne j$, and using the fact that the number of integers in the interval $[a+1,a+n]$ divisible by $d$ is
  $$ N_d(a,n) = \left\lfloor \frac{a+n}{d} \right\rfloor - \left\lfloor \frac{a}{d} \right\rfloor, $$
we get
\begin{align*}
  \sigma_n(a) 
     &= \sum_{1\le i\ne j\le n} \sum_{d\mid\gcd(a+i,a+j)} \mu(d) \\
     &= \sum_{d=1}^{n} \mu(d)\cdot N_d(a,n)(N_d(a,n)-1) \\
     &= \sum_{d=1}^{n} \mu(d)\cdot\left( \left\lfloor \frac{a+n}{d} \right\rfloor - \left\lfloor \frac{a}{d} \right\rfloor \right) \left( \left\lfloor \frac{a+n}{d} \right\rfloor - \left\lfloor \frac{a}{d} \right\rfloor - 1\right) \\
     &= \sum_{d=1}^{n} \mu(d)\cdot\left( \frac{n}{d} + \theta_n(a,d) \right)\left( \frac{n}{d} + \theta_n(a,d) -1\right),
\end{align*}
where $|\theta_n(a,d)|\le\frac12$. It follows that
  $$ \sigma_n(a) = n^2\ \sum_{d=1}^{n} \frac{\mu(d)}{d^2} +O\left(n\sum_{d=1}^n\frac1d+n\right) = \frac6{\pi^2}\,n^2 + O(n\log n) $$
as $n$ grows (uniformly in $a$).