Let $P_n$ be the sequence of prime numbers, where $P_0=2$.
Given $m\in\mathbb{N}$, how can we construct $f(x)$ such that:
$\displaystyle\forall{0}\leq{i}\leq{m}:f(i)=P_i$
$\displaystyle\int\limits_{0}^{m}f(x)=\sum\limits_{i=0}^{m}P_i$
For example, given $m=2$, how can we construct $f(x)$ such that:
$f(0)=2,f(1)=3,f(3)=5$
$\displaystyle\int\limits_{0}^{2}f(x)=2+3+5=10$
Answers for specific values of $m$ will also be appreciated.
It's pretty easy to do if you take a piecewise defined function. For example you could define:
$$f(x)= \begin{cases} 2, &\text{if } x\in (-\infty,0]\\ 7-4x, &\text{if } x\in (0,1]\\ P(i), &\text{if } x\in (i-1,i] \text{ for } i\geq2. \end{cases} $$
The only "problem" here seems to be the start, since it requires $\int_0^1f(x)dx=2+3=5$ and $f(1)=3$, so we cannot simply work with a constant function. But $7-4x$ has an average value of 5 for $0\leq x\leq 1$, so the integral condition is fulfilled.
For $x>1$ the integral behaves like a sum for natural values of $x$: since the function is constant in every interval of length 1 you simply add a rectangle with height $f(x)=P(i)$ to the integral.
It get's more complicated, if you want a continuous or even continuous differentiable function. Then you could use splines or trigonomic functions which have the property that for $x\in (i-1,i]$ the average function value is equal to $P(i)$.