$40 \cdot 40 + 40 + 41 = 40(40 + 1) + 41 = 40 \cdot 41 + 41 = 41(40 + 1) = 41^2$, so $f(40)$ is composite.
Suppose $f(n) = n^2 + n + 41$ is prime for $0 \le n \le 38$. But $f(n + 1)$ is also prime: $39^2 +39 + 41 = 1601$. So, $f(n)$ is prime for $0 \le n \le 39$.
Does the solution to the problem look something like that?
edit: like some users noted I might have to check all nonnegative $n < 40$ manually. The other post didn't solve my problem because I have no idea what's going on there. So, all I want to do is to see how strong induction fails here.