FUNCTION
Schroeder_Numbers_List
Computes the first \e n values of the Schroeder sequence.
Interface
#include <codecogs/maths/combinatorics/sequences/schroeder_numbers_list.h>
using namespace Maths::Combinatorics::Sequences;
This function generates an array with the first n values in the Schroeder sequence, given by the following recurrent formula
$$S(n) = \frac{1}{n} ( (6n - 9) S(n-1) - (n-3)S(n-2) )$$
(1)
with initial values
$$S(1) = S(2) = 1$$
(2)
The Schroeder sequence is also defined by
$$S(n) = \frac{P(n)(3) - 3P(n-1)(3)}{4(n-1)}$$
(3)
where $P(n)(X)$ is the Legendre polynomial of order $n$.
Example:
#include <codecogs/maths/combinatorics/sequences/schroeder_numbers_list.h>
#include <iostream>
int main() {
std::vector<int> result = Maths::Combinatorics::Sequences::schroeder_numbers_list(10);
std::cout << "Number of values: " << result.size() << std::endl;
for (int i = 0; i < result.size(); i++)
std::cout << result[i] << " ";
std::cout << std::endl;
return 0;
}
Output:
Number of values: 10
1 1 3 11 45 197 903 4279 20793 103049
References
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html
Parameters
n
the number of Schroeder numbers to generate
Returns
an array of the first n values in the Schroeder sequence
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.