# Which odd composite numbers $n$ are strong-pseudoprime to no base $a$ with $1<a<n-1$?

In this question :

A composite odd number, not being a power of $3$, is a fermat-pseudoprime to some base

I did not hit my own intend. I only asked for the numbers $n$ that are not a fermat-pseudoprime to any base $a$ with $1<a<n-1$. What I really meant is, for which composite numbers $n$, there is no number $a$ with $1<a<n-1$, such that $n$ is strong-pseudoprime to base $a$.

In short :

Which odd composite numbers $n$ are strong-pseudoprime to no base $a$ with $1<a<n-1$ ?

This is a weaker requirement because $a^{n-1}\equiv 1\ (\ mod\ n\ )$ does not imply that $n$ is strong-pseudoprime to base $a$. This is the case, if $n=2^m\ u+1$ with $u$ odd and either $a^u\equiv 1\ (\ mod\ n)$ holds or $a^{2^ku}\equiv -1\ (\ mod\ n)$ holds for some $k$ with $0<k<m$.

According to my PARI/GP-program, the numbers below $1000$ are :

9  15  21  27  33  35  39  45  51  55  57  63  69  75  77
81  87  93  95  99  105  111  115  117  119  123  129  135  141  143
147  153  155  159  161  165  171  177  183  187  189  195  201  203  207
209  213  215  219  225  235  237  243  245  249  253  255  261  267  273
275  279  285  287  291  295  297  299  303  309  315  319  321  323  327
329  333  335  339  345  351  355  357  363  369  371  375  381  387  391
393  395  399  405  407  411  413  415  417  423  429  437  441  447  453
455  459  465  471  473  477  483  489  495  497  501  507  513  515  517
519  525  527  531  535  537  539  543  549  551  555  567  573  575  579
581  583  585  591  597  603  605  609  611  615  621  623  627  633  635
639  649  655  657  663  665  667  669  675  681  687  693  695  699  705
707  711  713  717  723  729  731  735  737  741  747  749  753  755  759
765  767  771  777  779  783  789  791  795  799  801  803  807  813  815
819  825  831  833  835  837  843  849  851  855  867  869  873  875  879
885  893  895  897  899  903  909  913  915  917  921  923  927  933  935
939  943  945  951  955  957  959  963  969  975  979  981  987  989  993
995  999

• Your list seems a mix of $($some$)$ multiples of $3$ and OEIS A$121707$. – Lucian Sep 19 '15 at 18:48
• Nice observation! – Peter Sep 19 '15 at 19:15
• It also seems, that the numbers $3p$, with $p>2$ prime, are all in the list. – Peter Sep 19 '15 at 19:20

We want to count the number of bases to which $n$ is a strong pseudoprime. For odd $n$, this is:
$$\left( 1+\frac{2^{\nu(n)\omega(n)}-1}{2^{\omega(n)}-1} \right)\prod_{p|n}(n',p')$$
where $\nu(n)=\min_{p|n} v_2(p-1)$, $v_2(x)$ is the exponent of the largest power of 2 dividing $x$, $\omega(n)$ is the number of prime factors of $n$, and $x'$ is the largest odd divisor of $x-1$. See Monier or Erdős and Pomerance.
If we want only two bases for which $n$ is a strong pseudoprime -- that is, $\pm 1$ -- then $\nu(n)=1$ and $(n',p')=1$ for every $p|n$. That $\nu(n)=1$ means there is at least one prime $p|n$ such that $p\equiv 3(4)$. I don't know that the condition $(n',p')=1$ for every $p|n$ can be simplified.