I need to find how many elements of order $k$ are in $S_n$ (where $k \leq n$).
So if $k$ is prime, it's easy: $k$ can't be the $\mathrm{lcm}$ of any integers besides itself and one's (which we're omitting).
So the length of the cycle then must be $k$, and the number of elements with $k$-length cycle representation in $S_n$ is given by
$$\dbinom{n}{k}(k-1)!$$
But it gets really tricky when $k$ is not a prime number...
I need to consider every set of integers that can divide $k$, and then, for every set, I need to find how many elements of that form are there...
Or maybe I'm missing something here?
I need help figuring that out.
Consider all cycle types of permutations in $S_{n}$ which have order $k$. Recalling that $\sigma, \tau \in S_{n}$ are conjugate if and only if they have the same cycle type, then it should just then be a matter of finding the number of conjugates of each cycle type with order $k$. This is given by
$$\frac{n!}{\prod_{i=1}^{s}(k_{i}! m_{i}^{k_{i}})}$$
where for each $i \in \{0, 1, \dots, s\}$, $m_i$ is a distinct integer appearing in the cycle type of your permutation, and $k_i$ gives the number of cycles of length $m_{i}$.