5

Say you had to add up to 10 by only used the positive integers of 1 and 2, they can be arranged by 1111111111 as the most digits needed and 22222 as the least, or say 2212111 would be another combination, how many ways can you make 10 by doing this? (Bearing in mind 221122 and 112222 are different)

PS I'm 15, so sorry if it is an obvious question.

EDIT: Just thought seeing as each digit could have 2 possible values and if it is the second then you then you will only have 9 values, so, are the possible combinations not 1(all digits are ones) + 9(9 different places for a 2 to be) + (8*2-1)(16 places for two - 1 as they can't be in the same place), etc, or am I wrong?

Peter
  • 53

2 Answers2

2

Let $f(n)$ be the number of ways to represent $n$ as an ordered sum of $1$'s and/or $2$'s. A representation is of two possible types (i) it starts with $1$ or (ii) it starts with $2$.

There are $f(n-1)$ representations Type (i) representations of $n$, and $f(n-2)$ Type (ii) representations of $n$. It follows that for $n\ge 3$ we have $$f(n)=f(n-1)+f(n-2).\tag{1}$$ Note that $f(1)=1$ and $f(2)=2$. Now we can use the recurrence (1) to calculate $f(3)$, $f(4)$, and so on up to $f(10)$.

Remarks: The sequence we get may look very familiar!

André Nicolas
  • 507,029
2

Bearing in Mind that $221122$ and $112222$ are different means that the order does matters.

Now $10$ can be represented as $\color{red}{1111111111}$ as you said, and $\color{red}{22222}$, now $10$ can be also be written as $$\color{red}{222211,2221111,22111111,211111111}$$

Which are $6$ different ways in total (That is if the order doesn't matter)

Now $1111111111$ and $22222$ can only be written in that way.

Now here is the question , how many ways you can write $222211$ ? let it be $k_1$

How many ways you can write $2221111$ ? let it be $k_2$

How many ways you can write $22111111$ ? let it be $k_3$

How many ways you can write $211111111$ ? let it be $k_4$

Now your final answer should be $k_1 + k_2 + k_3 + k_4 + 2$

user26486
  • 11,331
alkabary
  • 6,214
  • 1
    Ah, thanks, so k1 would be how many ways you can rearrange those 5 numbers so 5! , which is 120, and k2 would be 7! and etc, right? – Peter Jun 24 '15 at 22:50
  • @Peter $k_1=\frac{5!}{3!2!}$, because the $2$'s are all the same, $1$'s are all the same. $k_2=\frac{7!}{4!3!}$, etc. – user26486 Jun 24 '15 at 22:53
  • Unfortunately, it's not that simple. Not all rearrangements are different. If you swap the first two numbers in 22111, it doesn't change. – Plutoro Jun 24 '15 at 22:54
  • Of course! Because my algorithm would count 22211 3 times! Thanks – Peter Jun 24 '15 at 22:56
  • @Peter It counts it $3!2!$ ways. – user26486 Jun 24 '15 at 23:09