Decomposition of a natural number as sum of positive integers Let $n \in \mathbb{N}$ be a positive natural number and denote by $f(n)$ the number of decompositions of $n$ of the form $n = a+b+c+d$ where $a,b,c,d > 0$ are also positive natural numbers such that $ad-bc = 1$.
Is there a closed or a recursive formula for $f(n)$?
 A: Let us show that $f(n) = \phi(n)$ if we allow $a,b,c$ and $d$ to be $0$ as @JoachimKönig suggested. The equality $ad - bc = 1$ is equivalent to $nd - (b + d)(c + d) = 1$. Let us show that for every $s\le n - 1$ coprime with $n$ there exists a unique answer to the initial problem satisfying $c + d = s$. Indeed, we need to solve $nd - (b + d)s = 1$. We have $d = n^{-1}$ mod $s$ and $c = s  - d$. Also $b = (nd -1)/s - d$, notice that it is nonnegative. Finally, number $a$ is defined as $n - b-c-d$, and it is also nonnegative, otherwise $ad - bc = 1$ will not hold.
A: Here is a geometrical approach.
The expression $ad - bc$ is a determinant of matrix $ M =\left(\begin{smallmatrix} a &b \\ c &d\end{smallmatrix}\right)$ and $n$ is a sum of coordinates af the point $X = Mv_1$, where $v_1 = \left(\begin{smallmatrix} 1 \\ 1\end{smallmatrix}\right)$. The problem is equivalent ot the following
Statement. Let $X = (p, n - p)$ be a point on the line $x + y = n$ with non-negative integer coordinates.

*

*If there exists matrix $M$ with $\text{det}M  = 1$ such that $Mv_1 = X$  then $(n, p) = 1$;

*If $(n, p) = 1$ then there exists a unique matrix $M$ with the same properties.

Proof: We start with the first part. Denote $v_2 =\left(\begin{smallmatrix} 1 \\ 0\end{smallmatrix}\right)$ and let $Y = Mv_2$ be the image point of $v_2$.  
Matrix $M$ has unit determinant hence it preserves the area and consequently $S_{XOY} = \frac{1}{2}$. Now from the Pick's theorem applied to the $XOY$ we get that  there are no integer points on the segment $OX$ except $O$ and $X$; therefore $(p, n - p) = 1$.
Now assume that $p$ and $n$ are coprime. To show the existence take $Y$ as a vertice of a triangle with the smallest possible area $S_{OXY}$. Again, by Pick's Theorem, its area equals to $1/2$ and therefore $\text{det} M = 1$.
Uniqueness can be show as follows: assume that there are two different points $Y_1$ and $Y_2$.

Equality of the areas implies that $OX\parallel Y_1Y_2$. However the segment $Y_1Y_2$ is shorter than $OX$.Thus, the point $Y_3$ corresponding to the vector $Y_2 - Y_1$ (or $Y_1 - Y_2$) is on the segment $OX$, which is a contradiction.
