For RSA this code results much faster.
RSAHacking_GetPrivateKeyFromPublicKeyUsingModPowNoPrimeTable(e, N)
k = 2
SqrtN = Sqrt(N)
if((SqrtN & 1) == 0) SqrtN++
for(p = SqrtN; p > 2; p-=2)
if (true/*You can use more filters for p*/ && ModPow(2, p-1, p) == 1 && ModMul(N+1, 10, p) == 10)
q = N / p
d = (k * ((p - 1) * (q - 1)) + 1) / e
return (e, d, p, q)