How many ways to add to $50$ with $1, 4$ and $6$

295 Views Asked by At

So I get how to find the number of ways of getting a number with $2$ sets of numbers (ex: using $1$s and $2$s to get $10$). But I have no clue where to start to figure out how many ways to get a number using $3$ sets of numbers:

How many ways can you add to $50$ by using $1$s, $4$s, and $6$s?

Order matters and they count as a way ($1+4$ and $4+1$ is $2$ ways), but all $1$s or all $2$s in different orders count as one way ($1+1$ and $1+1$ is $1$ way).

Is there like a formula that I could use to figure this out? Thanks.

From the comments:

I tried using brute force with 2 numbers and found a pattern where the next number of ways = number of ways now + previous number of ways. But using brute force with 3 numbers I'm cant seem to find a pattern.

2

There are 2 best solutions below

19
On BEST ANSWER

You can write a recurrence. You can get $50$ by getting $49$ and adding $1$, by getting $46$ and adding $4$, or by getting $44$ and adding $6$. If $A(n)$ is the number of ways to get $n$ you have $$A(n)=A(n-1)+A(n-4)+A(n-6)\\A(0)=1\\A(n)=0 \quad n \lt 0$$ Unfortunately, the polynomial that comes out of this, $x^6-x^5-x^2-1,$ cannot be factored easily except for the factor $x+1$ so you are into using numeric approximations for the roots.

Added: to do it with a calculator you make a column for $n$ with the numbers from $0$ to $50$ and a column for $A(n)$. Start from the top, putting $A(0)=1$ because there is one way to add to $0$-don't add anything. Then for each $n$ compute the sum of the lines $1, 4, \text {and} 6$ above. The result up to $n=20$ is shown below. For example, you get $A(9)=A(8)+A(5)+A(3)=10+3+1=14$ and keep going. The image is from Excel, where I could just copy the formula down.

enter image description here

1
On

Hint:

Let $f(n)$ be the number of sums that evaluate to $n.$ So $f(5)=3$ because $$5=1+1+1+1+1=1+4=4+1$$

The sums that evaluate to $50$ can be splittet into $3$ groups

  • the group of sums that starts with $1$
  • the group of sums that starts with $4$
  • the group of sums that starts with $6$

How can the size of these groups be expressed by $f$?

How can this be used to express $f(50)?$

Finally, calculate $f(50)$ but try to avoid to calculate values you have already calculated otherwise the number of calculations will explode.