TITLE: What are the odds two permutations in S_n do NOT generate the whole group?
QUESTION [5 upvotes]: What are the odds two uniformly chosen elements of S_n span the whole group (or just the alternating group)?  Mathematica experements suggest those odds approach 1 - this might have been proven a long time ago.  How likely is it to get the alternating group or something much smaller?
Also, how can you efficiently find the size of the subgroup $\langle a,b\rangle$ in S_n ?  My crude tests consists of randomly multiplying the two permutations and seeing how many different elements you get.  Maybe there's a more efficient way to generate all the elements spanned by two permutation. 

You can generate the whole permutation group using a swap (12) and a shift (12...n).  I wonder if all two element generating sets are conjugate to this.

REPLY [7 votes]: Concerning the second part of the OP's question:

Also, how can you efficiently find the size of the subgroup $\langle a,b \rangle$ in
  $S_n$ ? My crude tests consists of randomly multiplying the two permutations and seeing
  how many different elements you get. Maybe there's a more efficient way to generate all
  the elements spanned by two permutation. 

There is a "classical" polynomial-time method known as the "Schreier-Sims" algorithm for finding the order of the subgroup of $S_n$ generated by a given set of permutations - just google it for further details. It has a number of improvements for dealing with groups of very large degree. Refinements of this were used by Sims to prove the existence of some of the large sporadic finite simple groups, including the Lyons group and the Baby Monster.
There are also very fast "one-sided Monte-Carlo" probabilistic algorithms for verifying that the group generated by a given set of permutations is $A_n$ or $S_n$. If they do, then "yes" will be returned rapidly with high probability. If they do not, then the algorithm does not terminate, so normally you would give up and use Schreier-Sims instead. This method is based on old results due to Jordan and others, which say that if $G \le S_n$ is transitive and contains an element of prime order $p$ with $n/2 < p < n-2$, then  $G = A_n$ or $S_n$.
For further details, see Akos Seress' book "Permutation Group Algorithms" Cambridge University Press, 2003, or my own book, with B. Eick and E.A. O'Brien,  "Handbook of Computational Group Theory", CRC Press, 2005.