Referring to previous results

Mathematica has a convenient mechanism to refer to previously computed
results in a given session. The symbol % can be used to refer to the last computed
result. %n can be used to access the result in the cell Out[n].


   Prime[ 5]


  PrimePi[ %]

Here, Prime[n] returns the nth prime and PrimePi[x] returns the number of
primes less than or equal to x.

The use of % and %n in expressions should be used very carefully since % refers to
the last computed output and not the one right above the current expression. If you
do another computation between using % and output you want to refer to, then you will
get incorrect results.

Up to Tutorial