MCPcopy Create free account
hub / github.com/Dobiasd/FunctionalPlus / collatz_seq

Function collatz_seq

test/readme_examples_test.cpp:99–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98namespace {
99std::list<int> collatz_seq(int x)
100{
101 std::list<int> result;
102 while (x > 1) {
103 result.push_back(x);
104 if (x % 2 == 0)
105 x = x / 2;
106 else
107 x = 3 * x + 1;
108 }
109 result.push_back(x);
110 return result;
111}
112}
113
114TEST_CASE("readme_examples_test - CollatzSequence")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected