First we will simplify $$f(x) = \sum^{n}_{r=1}\tan \left(\frac{x}{2^r}\right)\cdot \sec \left(\frac{x}{2^{r-1}}\right)$$
So $$f(x) = \sum^{n}_{r=1}\frac{\sin \left(\frac{x}{2^r}\right)}{\cos \left(\frac{x}{2^r}\right)\cdot \cos\left(\frac{x}{2^{r-1}}\right)} =\sum^{n}_{r=1} \frac{\sin \left(\frac{x}{2^{r-1}}-\frac{x}{2^{r}}\right)}{\cos \left(\frac{x}{2^r}\right)\cdot \cos\left(\frac{x}{2^{r-1}}\right)}$$
So $$f(x) = \sum^{n}_{r=1}\left\{\tan \left(\frac{x}{2^{r-1}}\right)-\tan \left(\frac{x}{2^r}\right)\right\}$$
Now expanding summation, We get $$f(x) = \tan x-\tan \left(\frac{x}{2^{n}}\right)$$
So $$f(x)+\tan \left(\frac{x}{2^r}\right) = \tan x$$
So $$g(x) = \lim_{n\rightarrow \infty} \frac{\ln (\tan x)-(\tan x)^n\cdot \lfloor \sin \left(\tan \frac{x}{2}\right)\rfloor}{1+(\tan x)^n}$$
Now Given $\displaystyle 0<x<\frac{\pi}{2}\Rightarrow 0<\frac{x}{2}<\frac{\pi}{4}\Rightarrow 0<\tan \frac{x}{2}<1\Rightarrow 0<\sin \tan \frac{x}{2}<\sin (1)<\sin \frac{\pi}{2}$
So we get $\displaystyle \lfloor \sin \tan \frac{x}{2} \rfloor = 1$
For continuity at $\displaystyle x = \frac{\pi}{4}$
$$k = \lim_{x\rightarrow \frac{\pi}{4}}\lim_{n\rightarrow \infty} \frac{\ln (\tan x)-(\tan x)^n }{1+(\tan x)^n}$$