# Counting bases to which numbers are pseudoprime

Let $n=p_1^{a_1}\cdots p_k^{a_k}$ be an odd composite. Then the number of bases $1\le b\le n-1$ for which n is a strong pseudoprime is

$$\left(1 + \frac{2^{k\nu}-1}{2^k-1}\right) \prod_{i=1}^k\gcd\left(n*,\ p_i^*\right)$$

where $x^*$ is the largest e such that $2^e|x-1$ and $\nu$ is the minimum of the $p_i^*.$

1. What is the analogous formula for pseudoprimes? I've seen it but misplaced the reference.

2. What is the original source of this formula? I've never seen an attribution, it's always stated as folk knowledge. Does it date back to the time of Fermat?

3. Similarly, what is the source of the formula above for strong pseudoprimes?

-
Is the formula in Theorem 1 here the base-counting formula you need? –  Ｊ. Ｍ. Sep 14 '11 at 0:34
@J.M.: That's it. Did this actually originate there? I thought it was a lot older. –  Charles Sep 14 '11 at 14:15
Well, I know something like this had to have been in one of Baillie's papers, but I've no idea if this showed up in other, earlier papers. –  Ｊ. Ｍ. Sep 14 '11 at 14:21

Baillie and Wagstaff give a formula for counting the number of bases a number is pseudoprime to. Given a prime factorization $n=\prod\limits_{k}p_k^{a_k}$, the number of bases $< n$ for which $n$ is a pseudoprime is given by
$$\prod_k \gcd(n-1,p_k-1)$$