trying to write a recursive function that counts the number of sequences that sum up to that number C++

后端 未结 6 1536
野趣味
野趣味 2021-01-20 02:01

Okay, so here is what I\'m trying to do. The user inputs a number. I\'m trying to write a recursive function that counts the number of sequences that sum up to that number (

6条回答
  •  悲哀的现实
    2021-01-20 02:36

    Let f(n) be the function we want, that generates sequences of integers that add to n, without permutations

    Define

    f(n) = g(n,n)

    g(n,p) = { i \in 1..min(n, p): [i g(n-i,i)] }

提交回复
热议问题