Let $f(n)$ be number of numbers $x \in \{1,2,\cdots ,n\}$, $n\in\mathbb{N}$, such that $gcd(x, n)$ is either $1$ or prime. Prove
$$\sum_{d|n} f(d) + \varphi(n) \geq 2n$$
For which $n$ does equality hold?
To prove the inequality 
\[ \sum_{d|n} f(d) + \varphi(n) \geq 2n, \]
we need to carefully analyze the function \( f(n) \) and the Euler's totient function \( \varphi(n) \).

1. **Define \( f(n) \):**
   \( f(n) \) is the number of integers \( x \) in the set \(\{1, 2, \ldots, n\}\) such that \(\gcd(x, n)\) is either 1 or a prime number.

2. **Express \( f(d) \):**
   For each divisor \( d \) of \( n \), let \( s(d) \) be the number of integers \( x \) in the set \(\{1, 2, \ldots, d\}\) such that \(\gcd(x, d)\) is a prime number. Then, we can write:
   \[ f(d) = \varphi(d) + s(d), \]
   where \(\varphi(d)\) is the Euler's totient function, which counts the number of integers up to \( d \) that are coprime with \( d \).

3. **Sum over all divisors of \( n \):**
   \[ \sum_{d|n} f(d) = \sum_{d|n} (\varphi(d) + s(d)) = \sum_{d|n} \varphi(d) + \sum_{d|n} s(d). \]

4. **Use the property of Euler's totient function:**
   It is known that:
   \[ \sum_{d|n} \varphi(d) = n. \]

5. **Combine the sums:**
   \[ \sum_{d|n} f(d) = n + \sum_{d|n} s(d). \]

6. **Analyze \( \sum_{d|n} s(d) \):**
   We need to show that:
   \[ n + \sum_{d|n} s(d) + \varphi(n) \geq 2n. \]
   This simplifies to:
   \[ \sum_{d|n} s(d) \geq n - \varphi(n). \]

7. **Count the integers \( k \) such that \( \gcd(k, n) > 1 \):**
   For each \( k < n \) such that \( \gcd(k, n) > 1 \), there exists a divisor \( d \) of \( n \) such that \(\gcd(d, k)\) is a prime number. This means that each such \( k \) is counted in some \( s(d) \).

8. **Conclusion:**
   Since the right-hand side counts exactly those \( k \) such that \( \gcd(k, n) > 1 \), we have:
   \[ \sum_{d|n} s(d) \geq n - \varphi(n). \]

9. **Equality condition:**
   For equality to hold, each \( k \) such that \( \gcd(k, n) > 1 \) must be counted in exactly one \( s(d) \). This is true when \( n \) has exactly one prime divisor, i.e., \( n \) is a prime number. Therefore, equality holds if and only if \( n \) is a prime number.

\(\blacksquare\)

The final answer is \( \boxed{ n } \) is a prime number.