OFFSET
1,1
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..65537
Wikipedia, GCD
FORMULA
a(2k+1) = 4 = 2*2.
a(2k) = 1 if 3|k, otherwise a(2k)=3. - Jon Perry, Nov 09 2013
EXAMPLE
a(1)=4 because this is the largest integer less than 5 and it's coprime to n=1.
a(2)=3 because 4 is not coprime to 2 but 3 is.
a(6)=1 because no other positive integer n<4 is coprime to 6=2*3.
MATHEMATICA
Max[Table[If[CoprimeQ[#, d], d, 0], {d, 4}]]&/@Range[100] (* Harvey P. Dale, Aug 27 2022 *)
PROG
(PARI) A231475(n, m=5) = for(k=1, m, gcd(n, m-k)==1&&return(m-k));
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
M. F. Hasler, Nov 09 2013
STATUS
approved