I would appreciate if somebody could help me with the following problem:

Q: How to define this in Mathematica.

RecurrenceTable[{a[2 n] == a[n] + 1, a[2 n + 1] == a[n] + 3, a[1] == 1},a,{n,1,10}]
  • $\begingroup$ You should be getting an error which tells you what the problem is: RecurrenceTable::overdet: There are fewer dependent variables than equations, so the system is overdetermined. $\endgroup$
    – flinty
    Jan 4, 2022 at 9:56

1 Answer 1


RSolve and RecurrenceTable can't seem to handle this.

You can at least get values from the sequence like this though:

sequence = Module[{a,n=1,seq = CreateDataStructure["LinkedList"]},
   seq["Append", 1];
   While[n < 100,
    a = seq["Part", n];
    seq["Append", a + 1];
    seq["Append", a + 3];
    ++n;]; Normal@seq

ListPlot[sequence, Filling -> Axis, AxesLabel -> {"n", "a[n]"}]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.