 Let $a_1,a_2,\dots$ be a sequence of integers satisfying $a_1=2$ and:
    $$a_n=\begin{cases}a_{n-1}+1, & \text{ if }n\ne a_k \text{ for some }k=1,2,\dots,n-1; \\ a_{n-1}+2, & \text{ if } n=a_k \text{ for some }k=1,2,\dots,n-1. \end{cases}$$
    Find the value of $a_{2022!}$.
1. We start with the given sequence \(a_1, a_2, \ldots\) where \(a_1 = 2\) and the recurrence relation:
   \[
   a_n = \begin{cases} 
   a_{n-1} + 1, & \text{if } n \ne a_k \text{ for some } k = 1, 2, \ldots, n-1; \\
   a_{n-1} + 2, & \text{if } n = a_k \text{ for some } k = 1, 2, \ldots, n-1.
   \end{cases}
   \]

2. We aim to prove by induction that \(a_n = \lceil n \phi \rceil\), where \(\phi = \frac{1 + \sqrt{5}}{2}\) is the golden ratio.

3. Base case: For \(n = 1\), we have \(a_1 = 2\). Since \(\lceil \phi \rceil = 2\), the base case holds.

4. Inductive step: Assume \(a_k = \lceil k \phi \rceil\) for \(k = 1, 2, \ldots, n-1\). We need to show that \(a_n = \lceil n \phi \rceil\).

5. From the recurrence relation, we have:
   \[
   a_n = a_{n-1} + 1 + f(n),
   \]
   where
   \[
   f(n) = \begin{cases} 
   1, & \text{if } n = a_i \text{ for some } i; \\
   0, & \text{otherwise}.
   \end{cases}
   \]

6. If \(a_i = n\), then \(i \leq n-1\). Therefore, we can write:
   \[
   a_n = n + 1 + \sum_{2 \leq k \leq n} f(k) = n + 1 + g(n),
   \]
   where \(g(n)\) is the number of elements from \(\{2, 3, \ldots, n\}\) that are in the sequence.

7. By the inductive hypothesis, \(a_k = \lceil k \phi \rceil\) for \(k = 1, 2, \ldots, n-1\). Thus,
   \[
   a_k \leq n \iff k \phi \leq n \iff k \leq \left\lfloor \frac{n}{\phi} \right\rfloor.
   \]

8. Therefore, the number of such \(k\) is:
   \[
   g(n) = \left\lfloor \frac{n}{\phi} \right\rfloor.
   \]

9. Substituting this back, we get:
   \[
   a_n = n + 1 + \left\lfloor \frac{n}{\phi} \right\rfloor.
   \]

10. Using the identity \(\left\lfloor x \right\rfloor + 1 = \left\lceil x \right\rceil\), we have:
    \[
    a_n = n + \left\lceil \frac{n}{\phi} \right\rceil = \left\lceil n \left(1 + \frac{1}{\phi}\right) \right\rceil.
    \]

11. Since \(1 + \frac{1}{\phi} = \phi\), we get:
    \[
    a_n = \left\lceil n \phi \right\rceil.
    \]

12. Therefore, by induction, \(a_n = \lceil n \phi \rceil\) for all \(n\).

13. Finally, we need to find \(a_{2022!}\):
    \[
    a_{2022!} = \lceil 2022! \cdot \phi \rceil.
    \]

The final answer is \(\boxed{\lceil 2022! \cdot \phi \rceil}\).