WorksMathematics
Constructing Large Euler Pseudoprimes through Carmichael Products
Abstract
Inspired by recent work on Carmichael numbers and by the construction of Sanchez, et al., we revisit the subset product construction of Alford, et al. We state a theoretical parallel variant of the pushdown algorithm and extend computational records in two ways. First, we construct a Carmichael number that is an Euler pseudoprime to every base up to , which includes the first prime numbers. Second, we extend the known list of Carmichael numbers with exactly prime factors from to .
Introduction
Carmichael numbers are composite numbers for which for all . They are pseudoprimes, since they satisfy the conclusion of Fermat’s little theorem despite being composite.
These numbers have fascinated analytic number theorists and algorithmic number theorists alike, and the two groups have influenced each other in profound ways. In the introduction to Alford, Granville, and Pomerance’s proof of the infinitude of Carmichael numbers [3], their footnote credits the computational success of the subset-product problem as inspiring their own approach. In the other direction, [11, 10]’s arguments for the asymptotic count of Carmichael numbers provided the framework for Shallue & Webster’s proof of a heuristically optimal tabulation algorithm [12 Theorem 3]. We continue that tradition here, influenced by two recent results on Carmichael numbers.
Carmichael numbers as Euler pseudoprimes
Since Carmichael numbers are Fermat pseudoprimes, it has been common to see if they also satisfy the pseudoprimality of other, stronger tests based on Fermat’s little theorem. One example is the Solovay-Strassen test, which given a candidate prime and a base with checks to see if
and reports that is proven composite if the identity fails. The composite that pass the test are called Euler pseudoprimes to the base .
In [1] the authors present a novel construction. This involves finding a product of Carmichael numbers that forms an Euler pseudoprime to all integer bases up to 211, i.e. it fools the Solovay-Strassen test for the smallest 47 prime bases. Boltnev [5] previously constructed a strong (and thus Euler) pseudoprime to the first 350 prime bases, through 2357. His example also passes the next two prime bases, so it covers all prime bases up to 2377. We present a new construction which greatly improves upon this result; we have found a product of Carmichael numbers that forms an Euler pseudoprime to all integer bases up to 1172819.
Carmichael numbers with prime factors
It had long been conjectured that for every , there exists a Carmichael number with exactly prime factors. Larsen and Wright recently proved an asymptotic version of this result showing that for all sufficiently large, there exists a Carmichael number with exactly prime factors [8]. In private correspondence, Larsen indicated that it might be possible to make the bound effective and guessed that doing so would result in on the order of . This is significantly beyond our ability to bridge the known counts of 19565220 from [2]. Nonetheless, we revisited this computation and extended this result to 340210163, a factor of 17 improvement.
Organization
The remainder of the paper is structured as follows. § 2 provides the necessary background on Carmichael numbers and pseudoprimes and provides a summary of the pseudoprime construction technique of [1]. § 3 reviews Algorithm 1 of [2] and explains how it may be run efficiently in a parallel computing environment. Section 4 explains the required modifications and additions to the subset product algorithm to find an Euler pseudoprime to many bases. § 5 provides some details of the implementation and of the computational results.
Background
We frequently recognize Carmichael numbers via their prime factorization.
Theorem 1 (Korselt’s Criterion). A composite number is a Carmichael number if and only if is square-free and for all prime divisors of $n.
Robert Carmichael proved Korselt’s criterion in the context of the reduced totient function or the Carmichael function ,
where the are distinct prime divisors of and is Euler’s totient function. Later we will also refer to , the 2-adic valuation of , which returns the largest exponent such that . We can now state Korselt’s criterion in terms of .
Theorem 2 (Korselt’s Criterion). A composite number is a Carmichael number if and only if .
Some early views on the infinitude of Carmichael numbers came from the fact that is a Carmichael number if is a product of three primes. If the prime -tuples conjecture were true, then this family would produce infinitely many Carmichael numbers. However, the argument that won the day (often attributed to Erdős) is centered not around specific families of , but rather around numbers with some prescribed Carmichael Lambda value. Indeed, let
where are the ordered prime numbers and . Consider the set . If is large compared to , then it should be possible to find a subset product in that is 1 (mod ). The idea is that a subset product in takes a random value in and with enough such products it is likely that at least one such composite product will land on 1. Let be such a product. Then , and so it is a Carmichael number. It is possible to choose so that many pair-wise co-prime Carmichael numbers may be found as subset products in , and this was the key strategy of [2], which we explain in § 3.
Constructing an Euler pseudoprime from Carmichael numbers
See [1] for a fuller treatment of this topic.
Definition 1 (Index). The index of a Carmichael number is given by
In [1], a coarse classification of Carmichael numbers was constructed. We focus only on the class needed for this paper.
Definition 2 (Class A Carmichael numbers). A Carmichael number is considered to be in Class A if is even.
Lemma 1 ([1], Lemma 7). Let be a Carmichael number in Class A. Then there are Euler liars in and all have Jacobi symbol 1.
The Class A Carmichael numbers make good candidates for Euler pseudoprimes. We need a Lemma regarding the product of two Class A Carmichael numbers.
Lemma 2 ([1], Lemma 12). Let and with be Class A Carmichael numbers. If is a Carmichael number, then is in Class A if .
So, these two lemmas allow us to multiply Class A Carmichael numbers and retain their classification and Euler pseudoprimality properties.
Lemma 3 ([1], Lemma 13). Let and be Class A Carmichael numbers that are Euler pseudoprimes for every base less than the prime and not to itself. Assume . Then if is a Class A Carmichael number, it is an Euler pseudoprime for all bases up to and including .
Proof. Assume and are in Class A, which means that the multiplicative order of modulo for all is a divisor of . Thus the Jacobi symbol is 1, and so the Jacobi symbol for the product is also 1 for all bases less than . This makes the product also an Euler pseudoprime to all bases less than .
Now focusing on , the Jacobi symbol with is . By multiplying two such numbers, the Jacobi symbol becomes 1, and the product being Class A means that the power is also 1. This makes the product an Euler pseudoprime to the base as well. □
The above is sufficient to describe their method and we refer the readers to Sections 3–5 of [1] for their complete description. They used the table of Carmichael numbers produced by [12] to construct products that were again Carmichael numbers. They repeatedly invoked Lemma 3 in order to construct Euler pseudoprimes to consecutive prime bases. At each stage of their algorithm, they were able to account for one more prime base.
The practical difficulty in their construction is the antecedent “if is a Carmichael number.” This is unlikely to hold. Our solution, alluded to above, is to use the subset product construction to guarantee the antecedent is always satisfied.
Lemma 4. Let be a positive integer. Assume that and are Carmichael numbers with . Further assume
Then is also Carmichael.
Proof. Since and both are Carmichael numbers, their product is squarefree. Since and , their product is also equivalent to 1 modulo . The divisibility assumption of the Korselt criterion is then satisfied by the divisibility assumption of the lemma.
In the next section we will see that the result of Algorithm 1 naturally leads to the conditions of Lemma 4 being satisfied, and hence our Carmichael products will always themselves be Carmichael.
The only minor adjustment, to be explained below, is to guarantee the inequality on the 2-valuations in Lemma 2 is always satisfied. Having done that, we will show that all of the Jacobi symbols may be aligned at once rather than one at a time. For our purposes, a simpler version of Lemma 3 suffices, which we state without proof.
Lemma 5. Let and be Class A Carmichael numbers that are not base Euler pseudoprimes. Assume . Then if is a Class A Carmichael number, it is a base Euler pseudoprime.
The Subset Product Algorithm
We present a slight modification to the modular subset product algorithm of [2] suitable for a parallel computing environment. As set up, we choose some
where are the ordered prime numbers and . We let ; in particular is some power of 2. We construct the set , then find many disjoint subsets of that product to 1 modulo . Each such composite product is a Carmichael number.
Asymptotic Complexity
There is a rich literature on the modular subset product problem, only some of which we will review here. We start with the observation that the problem is NP-complete [7]. Despite this fact, there are many instances where a polynomial time algorithm exists. Understanding which instances are easy and which are hard requires the notion of density.
Definition 3. Let define a modular subset product problem, where our goal is to find a subset of the that products to modulo . The density of the problem is defined as , where is the base-2 logarithm.
In a rough sense, the density compares the count of subsets with the size of the group. For a random instance of the problem, a solution exists with high probability if and only if the density is greater than one. If the density is less than one and we are confident that a solution exists, a good strategy is to use lattice basis reduction [6]. If the density is one (the hardest instances), one could use a birthday-problem approach that costs time and space, or an improved version like [4] with running time for additive subset sum.
When constructing Carmichael numbers it is easy to generate instances with density much greater than one, so we will now focus on that case. The classic solution is dynamic programming: build a 2D table and fill it in at a cost of time and space. In our case is large enough that this solution becomes impractical, so we turn instead to the method of [9], which was improved in [2]. See the next subsection for the presentation and discussion of that algorithm.
Algorithm
In our construction of an Euler pseudoprime to many bases we needed to construct many Carmichael numbers, all with respect to the same and the same set . For this purpose we used [2 Algorithm 1].
We call this the “pushdown algorithm,” because at each step pairs of products are found which are multiplicative inverses modulo the next , pushing the new product down to a smaller subgroup of . By repeating the pushdown step for each of the prime powers dividing , the algorithm ends with a collection of disjoint products, all of which are the identity modulo , and hence each composite product is a Carmichael number.
The algorithm requires high density in order to succeed. Furthermore, choosing a with higher density results in more Carmichael numbers constructed.
Lines 4–12 and 23–25 are optionally included (or excluded) all at once. Not executing the optional lines decreases the number of elements that would have been in by at most 1 per round for a given . Since the goal is to have many Carmichael numbers, we assume the optional lines are executed, and this is how the original Algorithm 1 of [2] worked. We address the significance of these optional lines in Subsection 3.3.
We note that lines 13–22 can be accomplished with a bucket-style sort using at most buckets. Each bucket is jointly used by or and can only have one or the other element (if both are found, it is a match and removed).
An important implementation detail is that group elements are stored as a list of integers which are elements of (called the history), along with their product as an element of . In this way we can reconstruct the Carmichael number as an integer, while being able to calculate the needed residues in a constant number of group operations.
Theorem 3. Algorithm 1 has time complexity , measured in operations in the group . Here is the number of distinct primes dividing and .
Proof. The algorithm has a nested loop structure, where the outer loop has length and the inner loop has length .
For a given , processing via the bucket-style sort requires one pass at a cost of group operations, since for each we either pass it along, put it in a bucket, or pair it with an element in a bucket and pass the pair along.
Algorithm 1 Many Carmichael numbers
for to do
(Optional) fixable true
(Optional) Calculate
if (Optional) then
if there exists with then
Remove exactly one such from
else
fixable false
end if
end if
for do
if then
and remove from
else
Find such that , if one exists
if such an exists then
, and remove from
end if
end if
end for
if (Optional) fixable and then
(Optional) Multiply the remaining , add to
end if
end for
return , each composite element of which is Carmichael
Heuristic 4. Assume the elements of are uniformly distributed elements of . Then Algorithm 1 has expected time complexity , measured in group operations.
Heuristic justification. The total number of considered by the algorithm is
At each step in the outer loop, an expected fraction of the elements will be passed to the next stage immediately. Of the remaining, we expect them to pair up and for their product to be passed along. Thus we have the expectation that
where the last inequality follows as long as . (At most two rounds fail that inequality, and they do not affect the overall bound.) We conclude that the total number of is by bounding the resulting geometric sum.
At step we scan through the set of elements, either placing an element in one of the buckets or matching with an element in a bucket and removing both. Since we have access to the residue modulo , processing each element results in a constant number of group operations. □
Note that counting bit operations rather than group operations would make Theorem 3 a more accurate picture compared to Heuristic 4, as effectively the entirety of is carried along from step to step via the history portion of the element representation.
These bounds make no claims as to the density required to ensure that is nonempty with high probability; in practice we found it easy to construct with high enough density.
A parallel version of Algorithm 1
We describe two versions of a theoretical distributed-memory implementation of Algorithm 1. The key distinction is found in the inclusion or exclusion of the optional lines. The first, where we exclude the optional lines, is more elementary and provides a simple chunking structure. This version may actually be run sequentially if it is not feasible to have all of stored at once. It also uses no inter-process communication and may be preferred if inter-process communication is especially costly. The second version shows how to introduce inter-process communication and allow the execution of the optional lines.
Model. We assume processes with ranks , each with private memory, and point-to-point and tree-structured collective communication.
Parallel prime generation. The ability to generate primes in parallel was addressed in [2]. One simple method to accomplish this is by assigning certain fixed divisors of to given processors. In this way, we can create
where the union is a disjoint union and processor has . With the exception of the assignment of the fixed divisors for initialization, prime generation needs no communication among the processors.
Trivial parallelization. Processor simply runs Algorithm 1, where line 1 has the assignment . After each of processors finish their work, the elements in can be pooled together. The success of Algorithm 1 relies on having a sufficiently dense set of solutions to the subset product problem. This places a practical limit on the number of processors that can be used in this trivial parallelization before the expectation is that each local job would fail to find Carmichael numbers. Conservatively, each process might need
primes so that the final step is expected to be nonempty. We can use static partitioning by choosing
Heuristic estimates of are good once is fixed, so can be chosen before the computation begins.
Parallel version with communication. We explain how to accomplish Algorithm 1 in parallel while executing the optional lines. The guiding principle is that the elements of grow as increases, but the information needed to decide which elements to combine is small (residues modulo ). The algorithm therefore favors local work, communicates residues modulo freely, and communicates the elements or as rarely as possible. It does not matter if is treated as an actual integer formed as a product of primes or as a data structure that stores the prime factors explicitly. In either case, the asymptotic cost of communication remains the same.
We describe round of Algorithm 1 in a parallel environment. As with the trivial parallelization, line 1 is replaced with . And rank only has access to unless the instructions indicate communication.
Line 5 is computed by an all-reduce of the residues.
For lines 6–12, when , each process reports whether it holds an element congruent to and the lowest such rank, found with an all-reduce, deletes one such element. If none exist, set fixable to false.
Lines 13–22 are first accomplished locally. Unmatched elements are saved for parallel matching.
The remaining matches are found by a binary tree reduction over the residue tables.
Pairs of processors share their residue tables which contain the rank and surplus residues. When a match is found, only or are communicated as necessary.
The pairs produce a joint residue and rank table, which is used in the node above.
For lines 23–25, if fixable is true and the global leftover pool is nonempty, once the root’s table has no more matches, each process multiplies its own unmatched elements. These partial products are combined in a tree product into one last element of , which may be assigned to any processor.
The intent is to write this parallel code using a static partitioning of the work. Keeping in mind that most work is meant to be done locally, it is possible to redesign the above to allow dynamic partitioning. If drops below some threshold, processor can send all of its products in the first step of the tree reduction.
Euler Pseudoprimes to many bases — Linear Algebra over
It is simple to modify the above to create Class A Carmichael numbers whose products are also always in Class A. We need the inequality on the 2-valuations of Lemma 2 to be satisfied. There are two conceptually equivalent ways to accomplish this. First, we can run the prime generation phase on . Carmichael numbers produced this way satisfy . Second, we can replace (the power of 2) with when we run Algorithm 1. Numbers produced in this way satisfy . We either artificially lower the power of 2 for the prime generation phase or we artificially inflate the power of 2 for the subset product problem. In either case, , and for the remainder of the section we assume one of these two approaches has been taken.
Consider a set of bases and let denote the -th element of . The easiest case to consider (and the case we computed) involves consecutive primes starting with 2, but in principle could be any set of positive integers. For Lemma 5 to apply we need for all and all . In our computation we achieved this by restricting the primes in before running the pushdown algorithm to ensure all were greater than the largest element of .
By Lemma 1, we know half of all coprime bases are Euler liars (and thus have symbol 1). For each associate to it a vector over in the following way. Let the coordinate in the -th place of have the value 0 if is an Euler liar for and 1 otherwise (that is, the Jacobi symbol would be ). So long as , we can use linear algebra over to find a nontrivial solution to
The solution corresponds to a disjoint product of Carmichael numbers in which is an Euler pseudoprime to every . This product is itself Carmichael by Lemma 4.
Implementation Details
The code for this paper and the factors of the Euler pseudoprime are available at https://github.com/31and8191/euler-carmichael-computations.
Euler pseudoprime computation
Let
For , we look for primes . We require to be greater than 1.3 million, so that we do not have the Jacobi symbol equal to zero for any tested base. By using for pushdown, we ensure the resulting Carmichael numbers are Class A. The computation found 19551404 primes which combined via pushdown to give 90943 Carmichael numbers. The prime generation took less than 4 minutes with 24 jobs, and the serial pushdown took less than 9 minutes.
We form the matrix described in the previous section whose columns correspond to Carmichael numbers and rows to prime bases not dividing . The matrix with 90943 columns and 90947 rows has a one-dimensional kernel. We used a Python implementation of Gaussian elimination over to find a nonzero solution. Along with the 21 bases dividing , the resulting Carmichael number passes the Euler pseudoprime test for the first 90968 prime bases.
The solution vector corresponds to the product of 45413 of the Carmichael numbers, with a total of 8667018 prime factors. This number has 160558499 decimal digits. Constructing the final Carmichael number from the 90943 seed Carmichael numbers, including the matrix work, took approximately 11.5 hours.
We then used a separate program to verify that the factors are distinct, for each , , and that the product has . For each prime base up to 1172819, we computed the Legendre symbols and multiplied them to get the Jacobi symbol . It was 1 for every tested base. Because is Class A, we get the Euler condition.
Carmichael numbers with prime factors
With a new implementation of Algorithm 1 of [2], we extended the computation in that paper to demonstrate the existence of Carmichael numbers with exactly prime factors for every .
We use
We obtain 340210290 primes which we combine via pushdown into 1529840 base Carmichael numbers. We compute the possible numbers of prime factors of products of these Carmichael numbers and see that there are Carmichael numbers with factors for all . Combined with the original result, this gives all .
The prime generation took about 1 hour and 42 minutes with 24 jobs, the pushdown took about 37 hours, and checking the base Carmichael numbers took about 7 minutes.
Conclusion
We are indebted to the authors of [1] for an inspiring paper. Among other reasons, this gave us a perfect excuse to revisit the pushdown algorithm, eventually parallelize it, and create a new codebase for it.
Note that we took the prime bases up to some bound for convenience, but the techniques can be applied to any chosen set of bases. It seems likely that similar techniques could be applied to the construction of other pseudoprimes.
AI Disclosure
The authors used Anthropic Claude Opus 4.8 to write code for this project. They used OpenAI Codex for subsequent code development and review, checking numerical details, and paper planning. The authors wrote the text of the paper, with editorial support provided by LLMs. The authors have checked the content of this paper and take responsibility for it.
References
(1) Institute for Defense Analyses/Center for Computing Sciences
(2) Illinois Wesleyan University
(3) Butler University
References
- [1]Alejandra Alcantarilla Sánchez, Jolijn Cottaar, Tanja Lange, and Benne de Weger, Ours go to 211: Euler pseudoprimes to 47 prime bases (from Carmichael numbers), 2026, arXiv:2602.21840.
- [2]W. R. Alford, Jon Grantham, Steven Hayman, and Andrew Shallue, Constructing Carmichael numbers through improved subset-product algorithms, Math. Comp. 83 (2014), no. 286, 899–915. MR 3143697arxiv.org/abs/1203.6664
- [3]W. R. Alford, Andrew Granville, and Carl Pomerance, There are infinitely many Carmichael numbers, Ann. of Math. (2) 139 (1994), no. 3, 703–722. MR 1283874 (95k:11114)DOI
- [4]Anja Becker, Jean-Sébastien Coron, and Antoine Joux, Improved generic algorithms for hard knapsacks, Advances in cryptology—EUROCRYPT 2011, Lecture Notes in Comput. Sci., vol. 6632, Springer, Heidelberg, 2011, pp. 364–385. MR 2813651
- [5]Yu. F. Boltnev, Construction of strong pseudoprime Carmichael numbers passing the Miller-Rabin test for many first prime bases, Prikl. Diskretn. Mat., Suppl. (2025), no. 18, 258–262 (Russian).
- [6]Matthijs J. Coster, Antoine Joux, Brian A. LaMacchia, Andrew M. Odlyzko, Claus-Peter Schnorr, and Jacques Stern, Improved low-density subset sum algorithms, Comput. Complex-ity 2 (1992), no. 2, 111–128. MR 1190825DOI
- [7]Richard M. Karp, Reducibility among combinatorial problems, Complexity of computer computations (Proc. Sympos., IBM Thomas J. Watson Res. Center, Yorktown Heights, N.Y., 1972), The IBM Research Symposia Series, Plenum, New York-London, 1972, pp. 85–103. MR 378476
- [8]Daniel Larsen and Thomas Wright, Carmichael numbers with a specified number of prime factors, Integers 26A (2026), A15, 14 pp.
- [9]Günter Löh and Wolfgang Niebuhr, A new algorithm for constructing large Carmichael numbers, Math. Comp. 65 (1996), no. 214, 823–836. MR 1325872
- [10]Carl Pomerance, On the distribution of pseudoprimes, Math. Comp. 37 (1981), no. 156, 587–593. MR 628717DOI
- [11]Carl Pomerance, J. L. Selfridge, and Samuel S. Wagstaff, Jr., The pseudoprimes to 25 · 10^9, Math. Comp. 35 (1980), no. 151, 1003–1026. MR 572872 (82g:10030)
- [12]Andrew Shallue and Jonathan Webster, Algorithms for Carmichael numbers, Proceedings of the Seventeenth Algorithmic Number Theory Symposium (ANTS XVII), 2026, To appear; https://arxiv.org/abs/2506.09903v3.