This code-challenge is related to the code-golf question Analyzing Collatz-like sequences but the goal is quite different here.
If you are familiar with Collatz-like sequences you can skip to the section "The task".
We define a Collatz-like rule with 3 positive integers:
d > 1divisor
m > 1multiplier
i > 0increment
(In the original Collatz sequence
d = 2,
m = 3 and
i = 1.)
For a Collatz-like rule and a positive integer
n starting value we define a sequence
s in the following manner:
s(0) = n
k > 0and
s(k-1) mod d = 0then
s(k) = s(k-1) / d
k > 0and
s(k-1) mod d != 0then
s(k) = s(k-1) * m + i
An example sequence with
d = 2, m = 3, i = 5 and
n = 80 will be
s = 80, 40, 20, 10, 5, 20, 10, 5, 20, ....
Every sequence will either reach higher values than any given bound (i.e. the sequence is divergent) or get into an infinite loop (for some
s(t) = s(u) equality will be true).
Two loops are said to be different if they don't have any common elements.
You should write a program which finds a Collatz-like rule with many different loops. Your score will be the number of found loops. (You don't have to find all of the possible loops and higher score is better.)
The program could be specialized in any manner to produce the best score.
For proof the program should output the values of
i and the smallest values from every found loop.
For d=3 m=7 i=8 the loops are LOOP 15 5 43 309 103 729 243 81 27 9 3 1 LOOP 22 162 54 18 6 2 LOOP 36 12 4 So a valid proof with a score of 3 could be d=3 m=7 i=8 min_values=[1 4 2]
You can validate your result with this Python3 code. The program expects a list of space-separated integers
d m i min_value_1 min_value_2 ... as input.