||
I knew this problem in a WeChat group chat. It is said to be a problem for primary-school students. Here is the problem.
How many integers with all digits being just 1,2 or 3 and the sum of all digits being 10? For example, 12331 and 22222.
We could ask a more general question.
How many integers with all digits being just 1,2 or 3 and the sum of all digits being n?
Let a(n) denote the number of such integers. It is easy to see that a(1) = 1, a(2) = 2 and a(3)= 4.
Most importaintly, we have the following recursion relation.
a(n) = a(n-1) + a(n-2) + a(n-3).
We can understand the recursiion in the following way. Supposing the first digit is 1 (or 2 or 3), then rest number of integers must be a(n-1) (or a(n-2) or a(n-3)). Obviously a(n) is the sum of the thress cases.
It is certinaly a Fibonacci-type problem. It is very difficult to solve it because we'll have to find the solutions of a third-order equation. Anyway, I make it.
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-23 03:07
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社