OFFSET
1,2
COMMENTS
This list is connected to Pollard's p-1 algorithm, using the version of the algorithm iterating over all positive integers. Say a large number m has two distinct prime factors q and r, and using Pollard's p-1 algorithm someone wishes to obtain the prime factors. Say q = 223 and r = 307. As prime(48) = 223 and a(48) = 37, given a random "a" coprime to m the factor 223 will be discovered in 37 steps. Also, as prime(63) = 307 and a(63) = 17, given a random "a" coprime to m the factor 307 will be discovered in 17 steps. Note that after 37 steps both factors will be discovered, so the algorithm will return m, failing to discover either prime factor. Therefore, when 17 <= b < 37 the prime factor 307 will be discovered. Note that on rare occasions, for a given "a" value, by chance p divides (a^b! - 1), so it is possible that for some "a" values the actual b value will be less. But, for any "a" value and prime p = prime(n), it is guaranteed that b <= a(n).
LINKS
Samuel Harkness, Table of n, a(n) for n = 1..10000
Wikipedia, Pollard's p-1 algorithm
EXAMPLE
For n = 25, prime(25) = 97, so we will use p = 97. Then the prime factorization of p - 1 is p - 1 = 2^5 * 3. Note that for p - 1 to divide b!, the exponents for all prime factors in b! must be greater than or equal to the exponents for all prime factors in the prime factorization of p - 1. We find that 8! = 2^7 * 3^2 * 5 * 7 is the least b such that this is true, so a(25) = 8.
MATHEMATICA
a371924[p_] :=
Module[{a, d, f, u, v}, f = FactorInteger[p - 1]; d = {};
For[a = 1, a <= Length[f], a++,
u = f[[a]];
v = u[[1]]^u[[2]];
i = 1;
While[! Divisible[(u[[1]]*i)!, v], i++]; AppendTo[d, u[[1]]*i]];
Return[Max[d]]]
list = {};
For[p = 1, p <= 71, p++,
AppendTo[list, {p, a371924[Prime[p]]}]]
Print[list]
PROG
(PARI) a(n) = my(b=1, q=prime(n)-1); while (b! % q, b++); b; \\ Michel Marcus, Apr 15 2024
(Python)
from sympy import prime
def A371924(n):
m = prime(n)-1
b, k = 1, 1%m
while k:
b += 1
k = k*b%m
return b # Chai Wah Wu, Apr 25 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Samuel Harkness, Apr 12 2024
STATUS
approved