Observe that we have $n$ slots and we can place any one of $n$ values
in them, with the symmetric group acting on the slots and the values
simultaneously. We will solve this problem using Burnside.
What we have here is a special and unique variant of Simultaneous
Power Group Enumeration (as presented by Harary and Palmer and
Fripertinger, in a differet publication), with the group acting on the
$n$ slots where the $n$ values are placed being the symmetric group on
$n$ elements $S_n$ which acts on the values themselves at the same
time.
We can compute the number $q_n$ of functions by Burnside's lemma which
says to average the number of assignments fixed by the elements of the
group acting on the slots and values, which has $n!$ elements. But
this number is easy to compute.
Suppose we have a permutation $\beta$ from $S_n.$ If we place the
appropriate number of complete, directed and consecutive copies of a
cycle from $\beta$ on another cycle from $\beta$ (possibly the same)
then this assignment is fixed under the group action, and this is
possible iff the length of the first cycle from $\beta$ divides the
length of second cycle from $\beta$ and there are as many assignments
as the length of the first cycle from $\beta.$
This uses the recurrence by Lovasz for the cycle index $Z(S_n)$,
which is
$$Z(S_n) = \frac{1}{n} \sum_{l=1}^n a_l Z(S_{n-l})
\quad\text{where}\quad
Z(S_0) = 1.$$
Actually doing the computation we obtain for the number of
functions the following sequence:
$$1, 3, 7, 19, 47, 130, 343, 951, 2615, 7318, \ldots $$
which directs us to OEIS A001372.
This link includes an important observation, namely that what we have
here is the following unlabelled species:
$$\def\textsc#1{\dosc#1\csod}
\def\dosc#1#2\csod{{\rm #1{\small #2}}}
\textsc{MSET}(\textsc{CYC}(\mathcal{T}))
\quad\text{where}\quad
\mathcal{T} = \mathcal{Z} \times \textsc{MSET}(\mathcal{T}).$$
The Maple code to compute these is as follows.
pet_cycleind_symm :=
proc(n)
option remember;
if n=0 then return 1; fi;
expand(1/n*add(a[l]*pet_cycleind_symm(n-l), l=1..n));
end;
pet_flatten_term :=
proc(varp)
local terml, d, cf, v;
terml := [];
cf := varp;
for v in indets(varp) do
d := degree(varp, v);
terml := [op(terml), seq(v, k=1..d)];
cf := cf/v^d;
od;
[cf, terml];
end;
q :=
proc(n)
option remember;
local idx_colors, res, b,
flat, cyc_a, cyc_b, len_a, len_b, p, q;
if n=1 then
idx_colors := [a[1]]
else
idx_colors := pet_cycleind_symm(n);
fi;
res := 0;
for b in idx_colors do
flat := pet_flatten_term(b);
p := 1;
for cyc_a in flat[2] do
len_a := op(1, cyc_a);
q := 0;
for cyc_b in flat[2] do
len_b := op(1, cyc_b);
if len_a mod len_b = 0 then
q := q + len_b;
fi;
od;
p := p*q;
od;
res := res + p*flat[1];
od;
res;
end;
Addendum Sat Apr 21 2018. While the algorithm we presented here
will produce the correct result, it nonetheless admits of a
considerable improvement, namely that there is no need to flatten the
permutation because we can compute the contribution from a pair of two
cycle types of the permutation $\beta$ with the first type being
covered by the second by multiplying the number of coverings of the
first by the number of instances of the second, raising the result to
the power of the number of instances of the first. This yields the
following code.
pet_cycleind_symm :=
proc(n)
option remember;
if n=0 then return 1; fi;
expand(1/n*add(a[l]*pet_cycleind_symm(n-l), l=1..n));
end;
q :=
proc(n)
option remember;
local idx_colors, res, term_a,
v_a, v_b, inst_a, inst_b, len_a, len_b, p, q;
if n = 1 then
idx_colors := [a[1]];
else
idx_colors := pet_cycleind_symm(n);
fi;
res := 0;
for term_a in idx_colors do
p := 1;
for v_a in indets(term_a) do
len_a := op(1, v_a);
inst_a := degree(term_a, v_a);
q := 0;
for v_b in indets(term_a) do
len_b := op(1, v_b);
inst_b := degree(term_a, v_b);
if len_a mod len_b = 0 then
q := q + len_b*inst_b;
fi;
od;
p := p*q^inst_a;
od;
res := res + lcoeff(term_a)*p;
od;
res;
end;
This MSE link also
does Power Group Enumeration, as does this MSE link
II.