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

Function collatz_seq

test/fwd_test.cpp:156–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156std::list<int> collatz_seq(int x)
157{
158 std::list<int> result;
159 while (x > 1) {
160 result.push_back(x);
161 if (x % 2 == 0)
162 x = x / 2;
163 else
164 x = 3 * x + 1;
165 }
166 result.push_back(x);
167 return result;
168}
169
170TEST_CASE("fwd_test - collatz")
171{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected