2

It is given 3 numbers : 1, 3, and 5, you were told to write numbers by adding those 3 numbers, for example: There are 8 ways of writing the number 6

6 = 1 + 5

6 = 5 + 1

6 = 3 + 3

6 = 1 + 1 + 1 + 3

6 = 1 + 1 + 3 + 1

6 = 1 + 3 + 1 + 1

6 = 3 + 1 + 1 + 1

6 = 1 + 1 + 1 + 1 + 1 + 1

How many ways are there to write the number 12. The problem is, I need to finish it quick. I can do it manually, but it'll take some time. Can anybody help me? Just giving hints would help a lot! Thanks

Godlixe
  • 333

2 Answers2

3

There are three distinct ways to write 12 as the sum of 1s, 3s and 5s:

1) Write 11 as the sum of 1s 3s and 5s and then add an extra 1

2) Write 9 as the sum of 1s, 3s and 5s and then add an extra 3

3) Write 7 as the sum of 1s, 3s and 5s and then add an extra 5

So if $f(n)$ is the number of ways of writing $n$ as the sum of 1s, 3s and 5s then we have

$f(12) = f(11) + f(9) + f(7)$

But by a similar argument we know that $f(11) = f(10) + f(8) + f(6)$. So

$f(12) = f(11) + f(9) + f(7) \\=f(10)+f(9)+f(8)+f(7)+f(6) \\=2f(9)+f(8)+2f(7)+f(6)+f(5) \\=3f(8)+2f(7)+3f(6)+f(5)+2f(4) \dots$

gandalf61
  • 15,326
0

Since $1$, $3$, and $5$ are all odd, there must be an even number of summands to get to $12$. You can't do it with just two summands, but you can with any even number from four to twelve:

$$\begin{align} \{3,3,3,3\}&\times1\\ \{5,3,3,1\}&\times12\\ \{5,5,1,1\}&\times6\\ \{3,3,3,1,1,1\}&\times20\\ \{5,3,1,1,1,1\}&\times30\\ \{3,3,1,1,1,1,1,1\}&\times28\\ \{5,1,1,1,1,1,1,1\}&\times8\\ \{3,1,1,1,1,1,1,1,1,1\}&\times10\\ \{1,1,1,1,1,1,1,1,1,1,1,1\}&\times1 \end{align}$$

where the number after the $\times$ is the number of different ways the summands in the given set can be arranged. This gives a total of

$$1+12+6+20+30+28+8+10+1=116$$

This is the quickest way I can think of to get the count for the specific number $12$. (If there's a quicker way, I'd like to see it!) In general, for larger numbers, the recursive formula

$$f(n)=f(n-1)+f(n-3)+f(n-5)$$

as explained in gandalf61's answer, is undoubtedly better. The sequence of $f(n)$'s is A060961 in the OEIS.

Barry Cipra
  • 79,832