OFFSET
1,1
COMMENTS
It seems (although it is far from proved) that except for 4 and 8, if the routine declares n a prime, then it is.
FORMULA
a(n) ~ 3n log(3n). - Arkadiusz Wesolowski, May 23 2023
EXAMPLE
For n = 8, QR = {0, 1, 4} and MR = {0, 1, 2, 4}, so QR is a subset of MR, but 8 is not prime, so 8 is in the sequence.
MATHEMATICA
With[{s = Association@ Table[n -> SubsetQ @@ Map[Union@ # &, {Array[PowerMod[2, #, n] &, n - 1, 0], Array[PowerMod[#, 2, n] &, n - 1]}], {n, 10^3}]}, Rest@ Keys@ KeySelect[s, Or[! PrimeQ@ # && Lookup[s, #] == True, PrimeQ@ # && Lookup[s, #] == False] &]] (* Michael De Vlieger, Jul 30 2017 *)
PROG
(PARI) quad(n)=local(v, vc); vc=1; v=vector(n-1); for (i=1, n-1, v[vc]=i^2%n; vc++); v
mr(n)=local(v, vc, m); vc=1; v=vector(n-1); m=1; for (i=1, n-1, v[vc]=m%n; m=(2*m)%n; vc++); v
mqsort(n)=local(u, v); u=vecsort(mr(n)); v=vecsort(quad(n)); [u, v]
mqcomp(n)=local(w, wl, qc, pr); w=mqsort(n); wl=length(w[1]); qc=1; for (i=1, wl, pr=0; for (j=1, wl, if (w[2][i]==w[1][j], pr=1); if (pr==1, break)); if (pr==0, break)); pr
for(i=1, 500, if (isprime(i)!=mqcomp(i), print1(i, ", ")))
CROSSREFS
KEYWORD
nonn
AUTHOR
Jon Perry, May 08 2003
EXTENSIONS
More terms from David Wasserman, Sep 21 2004
STATUS
approved