The number $n = 4$ has the following $8$ compositions $(4),(3, 1),(2, 2),(2, 1, 1),(1, 3),(1, 2, 1),(1, 1, 2),(1, 1, 1, 1).$
The equation $\lambda_{1} + \dots + \lambda_{k} = n$ has $^{(n-1)}\text{C}_{(n-k)}$ positive integral solutions.
$k$ can be $1$ Or $2$ Or $3$ Or $\dots n.$
So, total number of solutions OR total number of compositions for $n$ is :
$^{(n-1)}\text{C}_{0} + ^{(n-1)}\text{C}_{1} + ^{(n-1)}\text{C}_{2} + \dots + ^{(n-1)}\text{C}_{(n-1)}$ which is $2^{(n-1)}.$
So, for $n=10,$ the answer will be $512.$
https://www.goclasses.in/
$\textbf{Alternative Method :}$
Consider an array of $n$ ones. A composition of $n$ can be uniquely characterized by grouping the ones into blocks such that the fist block has $\lambda_{1}$ ones, the second block has $\lambda_{2}$ ones, and so on. To ”encode” such composition we can interlace $n - 1$ blank squares among the $n \;1\text{’s}.$
Each square can be either left empty or we can replace it by a plus sign. For instance for the composition $(2, 1, 1)$ of the number $4$ we have $11 + 1 + 1$ (ignoring the squares). At each square, we can either leave it blank or replace it by a plus sign. Clearly, there are $2^{(n-1)}$ ways to do this.