There's some discussion related to your question.
As for algorithm, just take even involution with maximal support and try to find an even element of order 3 such that union of that partitions is just $(n)$; this pair will generate the whole group. That "greedy" algorithm will suffice if $n > 9$. Take that maximal involution $I = (12)(34)\dots(4k-1, 4k)$; take element $T$ of the form $(235)(679)..(4l+2, 4l+3, 4l+5), 4l+5 < 4k$ "connecting" all but maybe one 2-cycle. Now you have remaining fixed points (from 0 to 3) and 0 or 1 leftover 2-cycle. Number of holes in support of $T$ intersected with support of $I$ is at least $k+1$. Now arrange leftovers in pairs and connect it with support of $I$ adding 0 to 2 3-cycles to $T$ taking up no more than 3 holes. That "algorithm" (it admits closed form, obviously) is even 4-periodic in $n$. I'm not paying attention to primitivity, so this can be true only by coincidence.
Upd: there's whole article about explicit $(2,3)$ generators for $A_n$ and $S_n$