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}]
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI 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}]
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]"}]