There is a theorem which says that:Given a finite state automaton having $n$ states, if there exists a string $w$ whose length satisfies $n \leq |w| \leq 2n-1$ then the language accepted by the automaton is infinite.I understand the constraint $|w| \geq n$, but I don't understand why the constraint $|w| \leq 2n-1$ is there.
Condition for infinitude of the language of a finite state automaton
automata;finite automata
In the worst-case scenario, your NFA could look like this:The smallest $w$ for which it is guaranteed to loop (forcing it to accept an infinite language) has size $2n-1$.