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].

In[23]:=

   Prime[ 5]

Out[23]=

  11

In[24]:=

  PrimePi[ %]

Out[24]=

  5

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