OFFSET
2,2
LINKS
Michel Marcus, Table of n, a(n) for n = 2..5000
EXAMPLE
The positive integers k, k <= 6, where the positive integers <= k and coprime to k are also coprime to 6, are 1,2,6. So a(6) = the largest of these < 6, which is 2.
MATHEMATICA
f[n_] := Select[Range[n], GCD[ #, n] == 1 &]; g[n_] := Select[Range[n - 1], Times @@ GCD[f[ # ], n] == 1 &]; Max /@ Table[g[n], {n, 2, 80}] (* Ray Chandler, Dec 24 2006 *)
PROG
(PARI) isok(k, n) = my(v=select(x->(gcd(x, k) == 1), [1..k])); for (i=1, #v, if (gcd(v[i], n) != 1, return(0))); return(1);
a(n) = forstep (k=n-1, 1, -1, if (isok(k, n), return (k))); \\ Michel Marcus, Oct 20 2025
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Dec 24 2006
EXTENSIONS
Extended by Ray Chandler, Dec 24 2006
STATUS
approved
