How to find the value of $\int_{0}^{\pi}f(x)dx$ given some conditions. 
Suppose $f$: $\mathbb{R}$ to $\mathbb{R}$ is continuous and we have $\int_{k/2^n}^{(k+1)/2^n} f(x) dx = 2^{-n}$ for all $k \in \mathbb{Z}$ and $n \in \mathbb{N}$. We need to find the value of $\int_{0}^{\pi}f(x)dx$.

My first goal is to find a series such that its sum equals to $\pi$, but it is quite hard to find such series since the denominator is power of 2.
Then I use Mean Vaule theorem to do it. There exists a $c\in[\frac{k}{2^n},\frac{k+1}{2^n}]$ such that $\int_{\frac{k}{2^n}}^{\frac{k+1}{2^n}} f(x) dx = f(c)\frac{1}{2^n}=\frac{1}{2^n}$, hence $f(c)=1$ for $c\in[\frac{k}{2^n},\frac{k+1}{2^n}],\forall k,n$, then I conclude $f(x)$ identically 1.
Is there some mistakes in my thought? If correct then how can I show that $f(x)$ identically 1.
Thanks in advace.
 A: For all positive integers $L$ and $n$, it’s true that $$\sum_{k=0}^{L-1} \int_{k/2^n} ^{(k+1)/2^n} f(x) dx = \int_0^{L/2^n} f(x) dx$$ Now we have to make the upper limit equal to $\pi$. This can only work in a form of a limit, for otherwise we have a rational number. One way of doing this is to let $L=\lfloor 2^n \pi \rfloor $. Taking the limit as $n\to\infty$ on both sides, $$\int_0^{\pi}f(x) dx  = \lim_{n\to\infty} \sum_{k=0}^{L-1} 2^{-n} =\lim_{n\to\infty} \lfloor 2^n \pi\rfloor 2^{-n} =\pi $$
Similarly, by letting $L=\lfloor 2^n r\rfloor $ it can be proven that for any real number $r$, $$\int_0^r f(x) dx = r \implies f(r) = 1$$
A: You just proved that $f(c)=1$ for some $c$, not for all $c$.
Take any $x \in (0,1)$. For each $n$ there exists $k_n$ such that $\frac {k_n} {2^{n}} \leq x \leq \frac {k_n+1} {2^{n}}$. Now use the given equation, multiply by $2^{n}$ and take the limit. You will get $f(x)=1$ (by continuity). Hence $f(x)=1$ for all $x$.
A: Your intuition is correct, $f$ is identically $1$. But your argument needs to be improved. Here is my idea:
Assume by way of contradiction that $(\exists) x \in \mathbb{R}$ such that $f(x) \neq 1$. Since $f$ is continuous, $(\exists) \varepsilon >0$ such that $f(y) \neq 1, \ (\forall) y \in (x-\varepsilon, x+\varepsilon)$. Now, there exists some $k, n \in \mathbb{N}$ such that $$x-\varepsilon < \frac{k}{2^n}<\frac{k+1}{2^n}<x+\varepsilon$$ And now comes the Mean Value Theorem: Using the hypothesis, $(\exists) c \in \left[ \frac{k}{2^n},\frac{k+1}{2^n}\right]$ such that $f(c) = 1$, which is a contradiction.
A: Well, if:
$$\int\limits_{k/2^n}^{(k+1)/2^n}f(x)dx=2^{-n}$$
we know that over an interval of $1/2^n$ width the integral is this, and since we know that:
$$\bar{f}(x)=\frac{1}{b-a}\int_a^bf(x)dx$$
then we can use this to say that over this domain we have:
$$\bar{f}(x)=1\,\,\,\,\,\,\forall \,k,n$$
However note the following:
lets say we have a domain $x\in[a,b]$ and $a<c<b$. We could have:
$$f(x)=\begin{cases}f_1(x)& a\le x\le c\\f_2(x)& c<x\le b\end{cases}$$
if our functions satisfy $f_1(c)=f_2(c)$ then $f$ is still continuous but we could have a function where:
$$f(x+k)=f(x)+g(x;k)$$
could such a function exist such that $f(x+k)\ne f(x)$ i.e. $g(x;k)\ne 0$ but $f$ is continuous.
This was just a thought I had. In terms of proving that it is constant I believe looking at large $x$ will help us as the shrinking domain would effectively give the integral over two consecutive domains of $k$ as nearly equal, which would suggest that $f(x)=f(x+\epsilon)$ and so $f$ is constant. Now using the result from the mean value theorem gives $f=1$
