For question three, we can simply compute. Besides n=1, the next solution is 199981, as generated by this PARI/GP code:
Define $r(n)$ to be the number of ones in the digits of $n$:
r(n) = nn=n;cc=0;while(nn>0,if((nn%10)==1,cc=cc+1);nn=floor(nn/10));return(cc)
Then run a loop and output $i$ if the sum of $r(i)$ from 1 up to $i$ is equal to $i$:
yy=0;for(i=1,199981,yy=yy+r(i);if(yy==i,print(i)))
The output is this:
1
199981
This shows $f(1)=1$ and $f(199981)=199981$ and there are no other solutions less than 199981.
Similarly for question one, we define $g(n)$ to be the sum of the digits of $n$:
g(n) = nn=n; cc=0; while(nn>0,cc=cc+(nn % 10);nn=floor(nn/10));return(cc)
then calculate:
sum(i=1,1000000,g(i))
which yields the sum 27000001.
The problem here is with, as in many cases, the lack of a suitably decent conceptual model for what integration is about. In particular, you are trying to think of the integration as an area, and unfortunately this area model does not work in this particular case.
What you really should be thinking about - and at least for Riemann integration which is what this is - is that integration is accumulation. When you see a Riemann integral
$$\int_{a}^{b} f(t)\ dt$$
what this means is something like this: "Imagine a taphose, which can put out any amount of water, even imaginary 'negative water' that erases water already present. Put a bucket underneath. As time goes from $a$ to $b$, vary the flow rate so that $f(t)$ water is flowing at any time. The total amount of water that ends up in your bucket, positive or negative, is the integral."
Or phrased more abstractly, the integral represents the sum-total of accumulated change where the rate of change is given by the function $f$ being integrated. This is exactly why that an integral is the inverse of differentiation: if you want to reconstruct a function based on how it changes at each point and knowing its value at some starting point, you have to add up all the different changes between the starting point and the goal point to get the total change, and there are infinitely many of those, infinitely small and proportional to the function describing its rate of change at the intermediate points, i.e. the derivative.
In the case of a complex function, the small changes are complex numbers. Geometrically, this means they are 2-vectors (as $\mathbb{C}$ is a topological vector space over $\mathbb{R}$ and homeomorphic and isomorphic to $\mathbb{R}^2$). As you do
$$\int_{0}^{2\pi} e^{it} dt$$
the "taphose" is tapping out vectors, which are steadily rotating over time in a circle (because $t \mapsto e^{it}$ parameterizes the unit circle with constant speed). Suppose the vectors now represent displacements, say, imagine a hockey puck initially sitting at the origin (since the integral from $0$ to $0$ is 0). Then these displacement vectors start piling up into its total displacement, pulling it to and fro around the plane. Because these vectors are uniformly distributed across time, the same size, and pointing in every direction, the total displacement that results from their accumulation equals the same as would be had by pulling the object in every direction at once equally - i.e. no displacement at all. Thus
$$\int_{0}^{2\pi} e^{it} dt = 0$$
and this will be the case no matter how many times you go around the circle, since integrals are additive (just as water in a bucket is), so long as you go around a whole number of times only, and don't stop in the middle of a turn.
But note now that you are asking about
$$\int_{-n}^{n} e^{it} dt$$
where $n$ is now a natural number. To understand this, note that in the units of "time" that $e^{it}$ uses, it takes $2\pi$ (sometimes called, and personally which I prefer to call, $\tau$) units to make a whole rotation, and thus as we saw, 0 net displacement. But $2\pi$ is irrational, and thus no whole multiple of it can ever be a natural number. In particular, $2n$ is not a multiple of $2\pi$. As a result, this integral always stops partway and so leaves a net displacement.
Best Answer
The first problem you are trying to solve is
and the second problem you are trying to solve is
If you actually wrote out what you were doing, you'd find that when solving these problems, you are ultimately deriving
Since both of these numbers are restricted to be integers, these inequations are equivalent to
Note these are inequalities, not equalities! The solution to the chocolates problem is not "you can send 6 chocolates", but instead "you can send anywhere from 0 to 6 chocolates".
"6 chocolates" is merely the solution to "what is the largest number of chocolates you can send?"
(of course, natural language is very imprecise, and likely the problem intended to ask for the largest number, despite not saying so)