Two ideas are illustrated in this notebook:
1. Defining a function recursively.
2. Restricting the domain of a function in the definition of that function.

Just to be save, let's clear any assignment to the symbol g that we will use.

Clear[g]

The next line defines the function g in a recursive fashion.  Note the use of := in the syntax.  We don't want to evaluate the expression on the right until we have a specific value for n.

g[n_] := If[n == 1, 1, n*g[n - 1]]

See what happens with a variety of inputs.

g[5]

g[5.5]

This specific function only makes sense for integers.  Let's clear g and then modify the definition.  Note that _Integer in this syntax restricts the domain of the function.

Clear[g]

g[n_Integer] := If[n == 1, 1, n*g[n - 1]]

Test the new version.

g[5]

g[5.5]

For the last one, Mathematica returns the name of the output since we have not told Mathematica how to compute this output (or how to assign a value to g[5.5]).

g[-2]

The last one shows that we weren't really careful in specifying the domain. We really want only positive integers.  Here's a definition that makes this restriction.

Clear[g]

g[n_Integer?Positive] := If[n == 1, 1, n*g[n - 1]]

g[5]

g[5.5]

g[-2]