OFFSET
2,1
COMMENTS
Smallest pseudoprime k to base n such that gcd(k,n-1)=1.
Theorem (R. Steuerwald, 1948): if k is a pseudoprime to base b and gcd(k,b-1)=1, then (b^k-1)/(b-1) is a pseudoprime to base b.
From Robert Israel, Apr 14 2016: (Start)
a(n) is odd.
If m == n (mod a(n)) then a(m) <= a(n).
a(n) = 9 iff n == -1 (mod 9).
a(n) = 15 iff n == -1 (mod 15) but not (mod 9).
The first case where a(n) is not a semiprime (A001358) is a(383) = 561. (End)
LINKS
Robert Israel, Table of n, a(n) for n = 2..10000
MAPLE
Comps:= remove(isprime, [seq(k, k=9..10^6, 2)]):
f:= proc(n) local k;
for k in Comps do
if (n^(k-1)-1)/(n-1) mod k = 0 then return k fi
od:
error "ran out of composites"
end proc:
seq(f(n), n=2..100); # Robert Israel, Apr 14 2016
MATHEMATICA
Table[SelectFirst[Range[10^3], CompositeQ@ # && Divisible[(n^(# - 1) - 1)/(n - 1), #] &], {n, 2, 73}] (* Michael De Vlieger, Apr 14 2016, Version 10 *)
PROG
(PARI) a(n) = {my(k = 4); while ((n^(k-1)-1)/(n-1) % k, k++; if (isprime(k), k++)); k; } \\ Michel Marcus, Apr 14 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Thomas Ordowski, Apr 14 2016
EXTENSIONS
More terms from Michael De Vlieger, Apr 14 2016
STATUS
approved