Given a positive integer $n$ I would like to compute $f(n)$, the maximum possible length of a binary sequence such that any substring of it (subsequence with consecutive elements), of length $n$, never repeats.
For example, with $n = 1$, I have a maximum length of $2$, obtained with $(0, 1)$ or $(1, 0)$.
For $n=2$ I think the maximum should be $5$, which I can obtain with the sequence $(0,0,1,1,0)$.
Similarly, I can get a length of at least $9$ for $n=3$ and $15$ for $n=4$ with the sequences $(0,0,0,1,0,1,1,0,1)$ and $(0,0,0,0,1,0,0,1,1,0,1,1,1,0,1)$ respectively.
Obviously I can write an exhaustive search with a number of operations proportional to $2^{f(n)}$, but this starts to be impractical already for $n=6$.
Any hint for reducing the time complexity? Is it possible in the first place?