Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
Is the formula in Theorem 1 here the base-counting formula you need? – J. M. 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. – J. M. Sep 14 '11 at 14:21
up vote 2 down vote accepted

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)$$

I have no idea if this has previously appeared before the Baillie-Wagstaff paper, though.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.