Miller-Rabin Strong Pseudoprimes
C, 349 295 277 267 255 bytes

N,i;__int128 n=2,b,o,l[999];P(m){i&lt;N&amp;&amp;P(m&lt;2?l[i++]=n:n%m?m-1:n++);}main(r){for(P(scanf("%d",&amp;N));r|!b;)for(++n,b=i=N;i--&amp;&amp;b;){for(b=n-1,r=0;~b&amp;1;b/=2)++r;for(o=1;b--;o=o*l[i]%n);for(b=o==1;r--;o=o*o%n)b|=o&gt;n-2;for(o=r=1;++o&lt;n;r&amp;=n%o&gt;0);}printf("%llu",n);}


Takes 1-based input on stdin, e.g.:

echo "1" | ./millerRabin




It certainly isn't going to discover any new values in the sequence any time soon, but it gets the job done. UPDATE: now even slower!


Slightly faster and shorter, with inspiration from Neil A's answer (a^(d*2^r) == (a^d)^(2^r))
Significantly slower again after realising that all solutions to this challenge will be odd, so there is no need to explicitly enforce that we only check odd numbers.
Now using GCC's __int128, which is shorter than unsigned long long while also working with larger numbers! Also on little-endian machines, the printf with %llu still works fine.


Less-minified

N,i;
__int128 n=2,b,o,l[999];
P(m){i&lt;N&amp;&amp;P(m&lt;2?l[i++]=n:n%m?m-1:n++);}
main(r){
    for(P(scanf("%d",&amp;N));r|!b;)
        for(++n,b=i=N;i--&amp;&amp;b;){
            for(b=n-1,r=0;~b&amp;1;b/=2)++r;
            for(o=1;b--;o=o*l[i]%n);
            for(b=o==1;r--;o=o*o%n)b|=o&gt;n-2;
            for(o=r=1;++o&lt;n;r&amp;=n%o&gt;0);
        }
    printf("%llu",n);
}


(Outdated) Breakdown

unsigned long long                  // Use the longest type available
n=2,N,b,i,d,p,o,                    // Globals (mostly share names with question)
l[999];                             // Primes to check (limited to 999, but if you
                                    // want it to be "unlimited", change to -1u)
m(){for(o=1;p--;o=o*l[i]%n);}       // Inefficiently calculates (l[i]^p) mod n

// I cannot possibly take credit for this amazing prime finder;
// See https://codegolf.stackexchange.com/a/5818/8927
P(m){i&lt;N&amp;&amp;P(m&lt;2?l[i++]=n:n%m?m-1:n++);}

main(r){
    for(
        P(scanf("%llu",&amp;N));        // Read &amp; calculate desired number of primes
        r|!b;){                     // While we haven't got an answer:
        n=n+1|1;                    // Advance to next odd number
        for(b=1,i=N;i--&amp;&amp;b;){       // For each prime...
            for(d=n-1,r=0;~d&amp;1;d/=2)++r; // Calculate d and r: d*2^r = n-1
            // Check if there exists any r such that a^(d*2^r) == -1 mod n
            // OR a^d == 1 mod n
            m(p=d);
            for(b=o==1;r--;b|=o==n-1)m(p=d&lt;&lt;r);
            // If neither of these exist, we have proven n is not prime,
            // and the outer loop will keep going (!b)
        }
        // Check if n is actually prime;
        // if it is, the outer loop will keep going (r)
        for(i=r=1;++i&lt;n;r&amp;=n%i!=0);
    }
    printf("%llu",n);               // We found a non-prime; print it &amp; stop.
}




As mentioned, this uses 1-based input. But for n=0 it produces 9, which follows the related sequence https://oeis.org/A006945. Not any more; now it hangs on 0.

Should work for all n (at least until the output reaches 2^64) but is incredibly slow. I have verified it on n=0, n=1 and (after a lot of waiting), n=2.