A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/db/d27/n__bonacci_8cpp_source.html below:

TheAlgorithms/C++: math/n_bonacci.cpp Source File

Go to the documentation of this file. 40

std::vector<uint64_t>

N_bonacci

(

const

uint64_t &n,

const

uint64_t &m) {

41

std::vector<uint64_t> a(

43 if

(m < n || n == 0) {

54 for

(uint64_t i = n + 1; i < m; i++) {

58

a[i] = 2 * a[i - 1] - a[i - 1 - n];

73 const

std::vector<uint64_t> expected;

74 TestCase

(

const

uint64_t in_n,

const

uint64_t in_m,

75

std::initializer_list<uint64_t>

data

)

76

: n(in_n), m(in_m), expected(

data

) {

77

assert(

data

.size() == m);

80 const

std::vector<TestCase> test_cases = {

88 TestCase

(5, 15, {0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 31, 61, 120, 236, 464}),

91

{0, 0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 32, 63, 125, 248, 492, 976}),

92 TestCase

(56, 15, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})};

94 for

(

const auto

&tc : test_cases) {

97

std::cout <<

"passed"

<< std::endl;

std::vector< uint64_t > N_bonacci(const uint64_t &n, const uint64_t &m)

Finds the N-Bonacci series for the n parameter value and m parameter terms.

static void test()

Self-test implementations.

int main()

Main function.

Functions for the N-bonacci implementation.

represents single example inputs and expected output of the function longest_common_string_length


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4