I'm a beginner at Mathematica and trying to define a function for the Collatz conjecture, and here is my code:
g[n_] := g[n] = n/2 /; EvenQ[n]; g[n_] := g[n] = 3 n + 1 /; OddQ[n];
And I find that the definition for Odd n's would override the former definition,
?g gives only
g[n_] := g[n] = 3 n + 1 /; OddQ[n]
However, a definition like the following one will not be overriding the other definition:
f[x_] := x /; x > 0; f[x_] := -x /; x <= 0
Why is this the case and how should I fix this?