1

For example, k = 2; sum = 4. The answer would be 5: 1111, 112, 121, 211, 22

Is there a mathematical formula to count these?

  • 1
    There is a recursion available : for $k=2$, this recursion matches the Fibonacci numbers. For $k=3$, it's just $a_{k} = a_{k-1}+a_{k-2}+a_{k-3}$ if I'm not wrong. You should try proving the recursion at least for $k=2$. Then we can derive a formula using the theory of linear recurrences. – Sarvesh Ravichandran Iyer Dec 11 '21 at 12:26
  • 1
    @TeresaLisbon Nice ! I utterly forgot this application of the fibonacci-numbers ! – Peter Dec 11 '21 at 12:51

0 Answers0