Q: Finding Minimal $i$ such that $j$ Divides $ip$ and $k$ does not Divide $ip$ 
Given distinct positive compositve integers $j,k\le n$, what is the smallest integer $i=\prod_{p\le n}p^{a_p}$ such that

*

*$j$ divides $ip$ for some prime $p\le n$, and

*$k$ does not divide $ip$ for any prime $p\le n\,$?
when such values of $i$ exists?


Remarks:
A) Condition 1) is equivalent to saying that $\frac{j}{\text{gcd}(i,j)}$ is composite. The integer $i$ may be larger than $n$ but has no prime factor $p$ larger than $n$.
B) Given an integer $j$, I can describe the values of $k$ such that there exist values of $i$ satisfying 1-2). Given $j$, the integers $k$ are such that $j$ cannot be attained from $k$ sequentially by the operations (i) multiplying by a prime $\le n$ (i.e., $x\mapsto px$ with $p\le n$) and (ii) dividing by a prime factor of $k$ order 1 then multiplying by a prime factor $k$ already has (i.e., $x\mapsto xq/p$ where $p\vert x,$ $q\vert x$, and $p^2 \not \vert x$; and $p,q\le n$). In the sequence, steps (i) and (ii) can be used in any order and any number of times as long as the result at each step is $\le n$.
C) We can define a poset on the positive composite integers $\le n$ in the following way. If an integer $b$ can be obtained from an integer $a$ sequentially using (i) and/or (ii) then $a\preccurlyeq b$.
When there exists an $i$ satisfying 1-2), is there a way to prescribe a formula for $i$? Does the smallest such $i$ satisfy $i\le n$?

A: Let $J$ denote the multiset obtained from writing out the primefactors of $j=p_1 p_2 \cdots p_n$ into a corresponding set $J=\{ 1, 2, \dots, n \}$ (note that this is a multiset due to prime powers). Let $K$ and $I$ be defined similarly.
If we now talk about the conditions on these sets, the original conditions translate to:

*

*When adding $\{ i \}$, i.e. multiplying by $p_i \leq n$, to I, we get $J\subseteq I$.

*For all $\{ j \}$, $p_j \leq n$, we add to I, we get $K\nsubseteq I$.

Note that $\#I \geq \#J-1$ is necessary for the first condition and that $\#(K \setminus (I\cap K)) > 1$ is sufficient for the second condition.
We obviously can not have $k \nmid j$, since then no such $i$ would exist. Hence $K\nsubseteq J$, thus $\#(K\setminus (J\cap K)) \geq 1$.
If we now define $q \mid \gcd(j, k)$, where $q$ is a single prime number (note that $Q$ is defined similarly and $\#Q=1$), we can define:
$$i = \frac{j}{q}$$
or, equivalently:
$$I=J\setminus Q$$
Then $I$ naturally satisfies the first condition and the second condition can be seen by taking (note that $Q \subseteq K$):
$$\#(K \setminus (I\cap K)) = \#(K \setminus ((J\setminus Q) \cap K)) = \#(K \setminus (J \cap K))+1 \geq 1+1=2$$
Which shows the sufficient condition for the second condition.
To obtain larger values for $i$ you can always multiply any of the smallers ones by $r \leq n$ with $r \notin K$, as this will not affect the second condition.
Note also that when we take $q$ to be maximal we will get the minimal $i$, since we satisfy the necessary condition $\#I = \#J - 1$ with equality there are no prime numbers we can omit from $i$.
Since $j \leq n$ we will also have $i \leq n$.

A: We assume that $k \ge 2$ (the problem has no solution when $k=1$) and $j \ge 2$ (since $1$ is a solution when $j=1$ and $k \ge 2$).
Call $P_n$ the set of all prime numbers $\le n$ and $PD_j$ (resp. $PD_k$) the sets of all prime divisors of $j$ (of $k$).
First statement. Let
$$E_{j,k} := \left\{p \in PD_j : \forall q \in PD_k, \frac{k}{q} \nmid \frac{j}{p}\right\}$$
If $E_{j,k}$ is non-empty, the least solution is $j/(\max E_{j,k})$. Otherwise, there is no solution. This condition will be translated later.
Proof.
Indeed,
\begin{eqnarray*}
(1)
&\iff& \exists p \in P_n : j~|~ip  \\
&\iff& \exists p \in P_n : \frac{j}{j \wedge p} ~\Big|~i \frac{p}{j \wedge p} \\
&\iff& \exists p \in P_n : \frac{j}{j \wedge p} ~\Big|~i \mathrm{~by~Gauss~ lemma} \\
&\iff& \exists p \in PD_j : \frac{j}{p} ~\Big|~i \mathrm{~since~} j \ge 2. 
\end{eqnarray*}
Taking negations and replacing $j$ with $k$ yields
\begin{eqnarray*}
(2)
&\iff& \forall q \in PD_k \cup \{1\},~ \frac{k}{q} ~\nmid~i \\
&\iff& \forall q \in PD_k,~ \frac{k}{q} ~\nmid~i \mathrm{~since~} k \ge 2
\end{eqnarray*}
Given $p \in PD_j$, if some mutiple of $j/p$ itself satisfies condition $(2)$, then $j/p$ also satisfies condition $(2)$. The conclusion follows.
The condition on the set $E_{j,k}$ is not very tractable, we now translate into a clearer condition.
Second Statement. Denote by $\mathrm{rad}(j)$ the product of all prime numbers dividing $j$ without multiplicity. For every integer $a$ and prime number $p$, denote by $\nu_p(a)$ the exponent of $p$ in the decomposition of $a$ as a product of prime numbers. There are no solutions in only two cases:
$\bullet$ when $k$ divides $j$;
$\bullet$ when $k = q_0d$ for some $q_0 \in P_n \setminus PD_j$ and some divisor $d$ of $j/\mathrm{rad}(j)$.
Proof (a) When $k$ divides $j$, conditions $(1)$ and $(2)$ are incompatible.
Hence $k \nmid j$ is a necessary condition for the existence of solutions
Assume now that that $k \nmid j$ (namely there exists $p \in P_n$ such that $\nu_p(k)>\nu_p(j)$).
(b) If there exists $p_0 \in PD_j$ such that $\nu_{p_0}(k)>\nu_{p_0}(j)$, then $j/p_0$ is a solution. Indeed, for every $q \in PD_k$ and $\nu_{p_0}(k/q) \ge nu_{p_0}(k)-1 > \nu_{p_0}(j)-1 = \nu(j/p_0)$, so $k/q$ does not divide $j/p_0$.
(c) In the same way, if there exists $q_1 \ne q_2$ in $PD_k$ such that $\nu_{q_1}(k)>\nu_{q_1}(j)$ and $\nu_{q_2}(k)>\nu_{q_2}(j)$, then for every $p \in PD_j$, $j/p$ is a solution.
Assume now that none of the conditions (a), (b), (c) holds. Then there exists only one $q_0 \in PD_k$ such that $\nu_{q_0}(k)>\nu_{q_0}(j)$; moreover, this prime number $q_0$ does not divide $j$. For every $p \in PD_j$ and $q \in PD_k \setminus \{q_0\}$, $k/q$ does not divide $j/p$ since $\nu_{q_0}(k/q) = nu_{q_0}(k) > \nu_{q_0}(j) = \nu_{q_0}(j/p)$. Thus, the only way to prevent the existence of solutions is that $k/q_0$ divides all  quotients $j/p$ for $p \in PD_j$, or equivalently, that $k/q_0$  divides $j/\mathrm{rad}(j)$.
