Please give an example of a function $f:(0,\infty) \rightarrow \mathbb{C}$ with the following properties:
(a): $f \in L^p(0,\infty)$ for $2 \leq p \leq \infty$, but $f \notin L^p(0,\infty)$ if $1 \leq p < 2$
(b): $f \in L^p(0,\infty)$ for $2 < p < 4$, but not for $p$ outside this range
I'm pretty sure I figured out part (a) by letting $$ f(x) = \sum_{n=1}^\infty \frac{1}{n} {\large \chi}_{[n,n+1)} (x)$$ but I'm not sure about part (b). I'd appreciate any help.
Something like $$ (a)\quad f(x) = \frac{1}{\sqrt{1+x}\log(2+x)}, \qquad (b)\quad f(x) = \frac{1}{x^{1/4}(1+x^{1/4})}\,. $$