But for PE, you don't need a formula, you need code...
P3 (nA, nX) => (nA.P2(nA-1,nX)+ nX.P3(nA,nX-1)/(nA+nX)
P2 (nA, nX) => (nA.P1(nA-1,nX)+ nX.P3(nA,nX-1)/(nA+nX)
P1 (nA, nX) => (nA)/(nA+nX)
Working down from the top... The probability of a sequence of 3 breaks down into either an A (of which there are nA remaining), followed by a sequence of 2 (with 1 less A to pick from); OR non-A (nX choices) followed by any string with 3 A's (recursive call, but with one less non-A), all divided by the total number of characters.
Similarly to get a trailing double, you need another A (nA choices) followed by the third (again with one less to pick from). If not, you're washed out and start again looking for a string of 3.
Finally, P1 the probability of an A is just the number or remaining A's over the total remaining characters.