This question is basic, but I do not know what is wrong.
Clear[a0,a]
a0=n;
a[n_]:=a0
But when I evaluate a[n-1] the output gives n which is same as a[n], it should be n-1 but why is it n? Could someone spot the error?
This question is basic, but I do not know what is wrong.
Clear[a0,a]
a0=n;
a[n_]:=a0
But when I evaluate a[n-1] the output gives n which is same as a[n], it should be n-1 but why is it n? Could someone spot the error?
a[n_] := n?? The reason this happens is that there is nothing that matches the patternn_on the right hand side of the definition oga[n_]. So no matter what you give as input, it will matchn_, but then this won't be used anywhere, Mathematica will just returna0, which contains the symboln, not the thing that matched the pattern_. – Marius Ladegård Meyer Jun 14 '16 at 15:31