Is there a mathematical way to solve this problem? The question goes something like this:

How many different ways can you add up 2, 3, and 5 to get a sum of 12. Numbers can be repeated, and all three numbers do not have to be used for each solution. For instance, 5 + 2 + 2 is an answer, and so is 2 + 5 + 2.

The answer is 5 different ways:


*

*5 + 5 + 2 

*2 + 2 + 2 + 2 + 2 + 2 

*3 + 3 + 3 + 3 

*3 + 3 + 2 + 2 + 2 

*5 + 3 + 2 + 2


Is there some equation or formula that can be used to solve this problem, or does it have to be done manually?
 A: Assuming that order of numbers doesn't matter, i.e. $5+5+2$ is considered the same as $5+2+5$ is considered the same as $2+5+5$ (as suggested by your list of ways in which $12$ can be written):
One way of approaching this is via Generating Functions.  A rather in-depth treatment of the topic as a whole is given in the book Generatingfunctionology by Herbert Wilf and is available legally for download free at the linked site.
Here, we use the generating function $(1+x^2+x^4+x^6+x^8+\dots)(1+x^3+x^6+x^9+x^{12}+\dots)(1+x^5+x^{10}+x^{15}+\dots) \\= \frac{1}{1-x^2}\cdot \frac{1}{1-x^3}\cdot \frac{1}{1-x^5}$
We pick this generating function so that the term picked from the first parenthesis represents the number of times we used a $2$ in our sum, the term picked from the second parenthesis represents the number of times we used $3$ in our sum, etc...
Although each summation in the parentheses are technically infinite series, we may choose to cut them off at an arbitrary finite point after the desired total in order to make calculations possible.  Once expanding, the coefficient of $x^n$ will be the number of different ways to create a sum of $n$ using the available numbers.
Expanding, $$\frac{1}{1-x^2}\cdot \frac{1}{1-x^3}\cdot \frac{1}{1-x^5} = 1+x^2+x^3+x^4+2x^5+2x^6+2x^7+\dots+4x^{11}+5x^{12}+5x^{13}+\dots\\+18x^{28}+19x^{29}+21x^{30}+\dots$$
This shows it is impossible to get a sum of $1$ with the above numbers, there are $5$ ways to write $12$ as a sum of $2$'s, $3$'s, and $5$'s and similarly there are $21$ ways to write $30$ as a sum of $2$'s, $3$'s, and $5$'s.

For the related question of in how many ways a number can be written as a sum where order does matter, your example is incorrect as that would imply that $5+5+2$ is considered different than $5+2+5$ which is also different than $2+5+5$, which would give you a total of $3+1+1+\binom{5}{2}+\binom{4}{1,1,2} = 27$ different ways to write $12$ as a sum of twos, threes, and fives.
This is, as mentioned in the comments above, a different problem and is much more difficult.
A: Here's a way to enumerate all sums of $5$, $3$, and $2$ that add up to $n$,
if we do not consider the order of the terms in the sums to matter.
Let's consider just sums of $2$ and $3$ at first.
If $n > 1$, there is at least one such sum that adds up to $n$.
To find a specific sum, take the remainder of $n$ after dividing by $3$,
and treat each remainder as a separate case:
Case 0: $n = 3m$. Then the sum is simply
$$
n = 3m = \overbrace{3+3+\cdots+3}^{m\ \text{times}} 
$$
Case 1: $n = 3m + 1$, where $m \geq 1$. Then the sum is
$$
n = 3(m-1) + 2\cdot2
  = \overbrace{3+3+\cdots+3}^{m - 1\ \text{times}} + 2 + 2
$$
Case 2: $n = 3m + 2$. Then the sum is
$$
n = 3m + 2 = \overbrace{3+3+\cdots+3}^{m\ \text{times}}  + 2
$$
These are the maximum numbers of $3$s that can appear in the sum,
depending on which case applies.
Once we have found such a sum in which the term $3$ appears $k$ times,
we can substitute $2+2+2$ for $3+3$ until the number of $3$s remaining
is less than $2$. There are therefore $\lfloor k/2 \rfloor + 1$
distinct sums consisting only of $2$s and $3$s without regard to order.
If we now consider sums using $2$, $3$, and $5$ as terms,
we can convert any such sum to a sum of just $2$s and $3$s by
substituting $5=3+2$ until no $5$s remain.
Working backwards, any sum using $2$, $3$, and $5$ can be obtained
by starting with a sum consisting only of $2$s and $3$s
of the form $n = 3a + 2b$ and then replacing $3+2$ with $5$
(rearranging the order of terms as needed) up to $\min\{a,b\}$ times.
In summary to generate all possible sums of $2$, $3$, and $5$
adding up to $n$, we find an integer $k$ such that either
$n = 3k$, $n=3k+2$, or $n=3k+4$ 
(only one of these will be possible).
We use the substitution $3+3=2+2+2$ to generate a list of
$\lfloor k/2 \rfloor + 1$ sums 
of the form $n = 3a + 2b$ (including the original sum).
From each of the resulting sums,
using the substitution $3+2=5$, we generate a
list of $\min\{a,b\} + 1$ sums of $2$, $3$, and $5$.
If we do not actually do the final step above, but simply
count $\min\{a,b\} + 1$ for each sum of the form $n = 3a + 2b$,
it is possible in this way to count the number of sums without actually listing all of them.
Moreover, we can subdivide the list of sums of $2$s and $3$s into
two sublists: all the sums that have more $2$s than $3$s,
and the sums that do not.
In the first sublist, if the number of $3$s in the sums has a minimum $p$
and maximum $p+2q$, then the total number of sums generated from this
sublist of sums is $(p+q+1)(q + 1)$.
In the second sublist, if the number of $2$s in the sums has a minimum $r$
and maximum $r+3s$, then the total number of sums generated from this
sublist of sums is $\frac12(2r+3s+2)(s + 1)$.
Hence all we actually need to do is to find the minimum and maximum values
of $a$ for which $3a+2b=n$ and $0 \leq a < b$,
and the minimum and maximum values of $b$ for which
$3a+2b=n$ and $0\leq b \leq a$, determine the values $p$ and $q$
or $r$ and $s$ to plug into each of the formulas above,
and add the two results together.
A: You can do ordered sums as a recurrence.  Let $A(n)$ be the number of ways to express $n$ as a sum of $2,3,5$.  We have $A(1)=0, A(2)=1, A(3)=1, A(4)=1, A(5)=3$ and the recurrence $A(n)=A(n-2)+A(n-3)+A(n-5)$.  You can make a spreadsheet to compute this.  Copy down makes it easy. I get $A(12)=27, A(40)=560287$ as examples.  As $n$ gets large the number is multiplied by about $1.4291$ each step, which is the largest root of $x^5=x^3+x^2+1$
