<s>[INST] 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?
 [/INST] 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.
</s>