Using Table Recursively
In my opinion, NestList
is the most direct answer to the question in the OP, i.e. to "create a list from entries of the list itself", as Leonid suggested as well. The simple example in the OP then becomes:
NestList[# + 1 &, 1, 4]
{1, 2, 3, 4, 5}
NestWhileList
allows a function to run until a certain condition is met, in those cases in which the number of iterations is not known a priori:
NestWhileList[# + 2 &, 1, # < 20 &]
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21}
I mention this example specifically because it highlights a behavior that trips me up from time to time: the generated item that finally falsified the condition is included in the results. This is the first point in the Details section of the docs for this function. Of course Most@NestWhileList[...]
can be used to remove that last item, if needed.
The tutorial on Applying Functions Repeatedly might be of interest as well.
Use RecurrenceTable
or RSolve
Clear["Global`*"]
Clear[lt]
RecurrenceTable[{lt[n + 1] == lt[n] + 1, lt[1] == 1}, lt, {n, 1, 5}]
(* {1, 2, 3, 4, 5} *)
Or find a general term of the table
sol = RSolve[{lt[n + 1] == lt[n] + 1, lt[1] == 1}, lt, n][[1]]
(* {lt -> Function[{n}, n]} *)
Verifying that the solution satisfies the equations
{lt[n + 1] == lt[n] + 1, lt[1] == 1} /. sol
(* {True, True} *)
Generating a table from the general solution
lt /@ Range[5] /. sol
(* {1, 2, 3, 4, 5} *)