We could invert the functions and go "backwards". So, a[n-1]
could be 2*a[n]
if 2*a[n]
is even (which it will always be, so we always have at least one possibility). But also, a[n-1]
could be a[n]/(n-1)
if that value is odd.
So, given a value for an index, we can compute possible previous values:
PreviousAs[{idx_Integer, value_Integer}] :=
With[
{evenCase = 2 value, oddCase = value/(idx - 1)},
Thread[{idx - 1, {evenCase, If[OddQ[oddCase], oddCase, Nothing]}}]]
We're given a value for index 8, and we encode this as {8,10}
. We want to go backwards 7 steps, so evaluate this to get the possible values for index 1:
Nest[Catenate@*Map[PreviousAs], {{8, 10}}, 7]
We can test that it works (although this test doesn't guarantee that we found them all--maybe my logic above was incomplete) by defining the "forward" function:
NextA[{idx_Integer, value_Integer?EvenQ}] := {idx + 1, value/2};
NextA[{idx_Integer, value_Integer?OddQ}] := {idx + 1, idx value}
and iterating on one of the candidates generated above:
Nest[NextA, <...copy/paste one of the candidates here...>, 7]
Hopefully we get {8,10}
back.