# Tips for an efficient way to plot a fractal-like function?

I have this function

$$f(x)=\sum_{k=1}^{\lfloor x\rfloor}\tan(k),\quad x\ge 1$$

Then I tried to plot several graphs with this code

f[x_]:=Sum[Tan[k],{k,1,Floor[x]}]
Table[Plot[f[x],{x,1,10^n}],{n,2,10}]


but after half hour or so the computer hang on (memory issues) and I restarted it. Clearly the code is not the more efficient for this task.

My question is: can you give me some tips to improve the performance of mathematica to draw this function? By example, it is possible to define a recursion, instead of a function, and draw it? It seems more appropriate to use a recursion instead of a sum to draw this function.

One possibility is to use Accumulate and Interpolation to create the function:

if = Interpolation[Accumulate @ Tan[N @ Range[10^8]], InterpolationOrder->0]; //AbsoluteTiming


{79.0832, Null}

Now, we can plot if over various domains:

Plot[if[t], {t, 1, 10^2}] Plot[if[t], {t, 1, 10^3}] Plot[if[t], {t, 1, 10^8}] If you need to go higher, then you will need to create a new InterpolatingFunction starting at 10^8.