Let $n \geq 2$ be an integer. Let $S$ be a subset of $\{1,2,\dots,n\}$ such that $S$ neither contains two elements one of which divides the other, nor contains two elements which are coprime. What is the maximal possible number of elements of such a set $S$?
To solve this problem, we need to find the maximal possible number of elements in a subset \( S \subseteq \{1, 2, \ldots, n\} \) such that \( S \) neither contains two elements one of which divides the other, nor contains two elements which are coprime.

1. **Define the mapping and its properties:**
   Consider the function \( f: S \rightarrow \{[n/2] + 1, \ldots, n\} \) which maps \( x \in S \) to \( 2^k x \) where \( 2^k x \in (n/2, n] \). This function is injective because if \( x \) and \( y \) are in \( S \) and \( x \mid y \), then \( f(x) \mid f(y) \), which contradicts the condition that \( S \) does not contain two elements one of which divides the other.

2. **Analyze the coprimality condition:**
   Since \( (x, y) > 1 \) for all \( x, y \in S \), and \( (x, y) \mid (f(x), f(y)) \), it follows that \( f(S) \) cannot contain two consecutive numbers. This is because consecutive numbers are coprime, and \( S \) cannot contain coprime elements.

3. **Determine the upper bound for \(|S|\):**
   To find the upper bound for \(|S|\), note that \( f(S) \) is a subset of \(\{[n/2] + 1, \ldots, n\}\) and cannot contain consecutive numbers. The number of elements in \(\{[n/2] + 1, \ldots, n\}\) is approximately \( n/2 \). Since \( f(S) \) cannot contain consecutive numbers, the maximum number of elements in \( f(S) \) is approximately half of \( n/2 \), which is \([n/4]\).

4. **Construct a set \( S \) that achieves this bound:**
   Consider the set \( S = \{k \mid k \text{ is even and } k > n/2\} \). This set satisfies the conditions because:
   - All elements are even, so no element divides another.
   - All elements are greater than \( n/2 \), so they are not coprime with each other.

   The number of such elements is approximately \([n/4]\).

Therefore, the maximal possible number of elements in such a set \( S \) is \(\left\lfloor \frac{n+2}{4} \right\rfloor\).

The final answer is \( \boxed{ \left\lfloor \frac{n+2}{4} \right\rfloor } \).