
Dylan K. answered 04/24/21
Versatile Tutor With a Focus on Math and Writing
There are several different functions that could fit this, but I understand where your confusion is coming from; it seems at first like an impossible task. The trick, though, is to remember that convergence for a sequences and convergence for a function are different, and that all we know for sure is that the function has to pass through the every point in the series; all the other points are unknown.
The second important point is that divergent does not necessarily mean that it goes off to infinity; it would still be divergent as long as it has the property that it doesn't converge to a value. For instance, consider the function f(x)=1/x+cos(2πx). Clearly, for any integer value of x, this will just evaluate to 1/x; therefore, our sequence an = 1/n+cos(2πn) = 1/n, which converges to 0 as n goes to infinity. However, you can see that the general function f ever converges on a single value, instead oscillating between -1 and 1+ε. If you want, you can also define a function that will have an arbitrarily large value for certain larger values of x that still maintains the desired property, but I will leave that as an exercise to the reader.