1) Let's show this function is $1-1$. To do this, we suppose $f(n_1) = f(n_2)$ and show that this forces $n_1 = n_2$.
So, if it's true that $f(n_1) = f(n_2)$, then this means that
$$4n_1 + 1 = 4n_2 + 1 \\
\Rightarrow 4n_1 = 4n_2 \\
\Rightarrow n_1 = n_2 $$
and we have demonstrated what is required. Thus, $f$ is $1-1$.
2) Let's see if the function is onto (it might not be). If it is, we should be able to choose any $m \in \mathbb{Z}$ and show that there is some $n \in \mathbb{Z}$ such that $f(n) = 3n - 1 = m$.
If this is true, then we will need $n = \dfrac{1}{3}(m + 1)$. The problem is that this might not be an integer! For example, if $m = 1$, then $n$ would need to be $\dfrac{2}{3}$, which is not an integer. Thus, there is no $n \in \mathbb{Z}$ such that $f(n) = 1$ and so the function is not onto.
EDIT: For fun, let's see if the function in 1) is onto. If so, then for every $m \in \mathbb{N}$, there is $n$ so that $4n + 1 = m$. For basically the same reasons as in part 2), you can argue that this function is not onto.
For a more subtle example, let's examine
3) $f : \mathbb{N} \to \mathbb{N}$ has the rule $f(n) = n + 2$. If it is onto, then, for every natural number $m$, there is an $n$ such that $n + 2 = m$; i.e. that $n = m - 2$. Now, we don't have the same problem as we did before, that is, we don't have to divide by anything to solve for $n$. Thus there is always an integer $n$ so that $n + 2 = m$.
BUT! If $m = 1$ (for example), then $n$ would have to be $1 - 2 = -1$ which is not a natural number, so this function is not onto either.
The point of all this is, we have to look closely at both the domain and codomain to answer these kinds of questions.
The amount of material used to make the sides of the walls is proportial to the surface area of the box. If $l$ is the length, $w$ is the width, and $h$ is the height, then the volume is
$$V = lwh$$
and the surface area (which we'd like to minimize) is
$$S = 2(lw+lh+wh)$$
We can reduce the minimization problem to minimizing a function of two variables if we write one of the three dimensions in terms of the volume and the other two. Let's arbitrarily choose height, so
$$h=\frac{V}{lw}$$
Now the surface area is a function of length and width
$$S(l,w) = 2\left(lw + \frac{V}{w} + \frac{V}{l}\right) = 2\frac{l^2w^2 + Vl+Vw}{lw}$$
Given that you mentioned learning about local min/max values in some multivariable functions, you should be able to minimize $S(l,w)$ from here on. Feel free to ask more questions if you have any. Hope this helps!
By the way, your intuition that the box is cubical is correct. This is a generalization of the square being the rectangle that minimizes perimeter for a fixed area.
Best Answer
One of the answers is wrong. $f(n) = n^2 +1$ is not one-to-one, it is two-to one. (Do you understand what I mean?). The reason why $f(n) = n-1$ is onto, is because for any integer $m$, the successor integer, $m+1$ corresponds to it. Explicitly, $f(m+1) = (m+1) -1 = m$