OFFSET
1,1
EXAMPLE
The smallest prime coprime to 30 is 7. The largest multiple of 7 that is < 30 is 28. The smallest multiple of 7 that is > 30 is 35. 28 is closer to 30 than 35 is, so a(15) = 28.
MATHEMATICA
cm[n_]:=Module[{nn=100, prs, cp, m1, m2}, prs=Prime[Range[PrimePi[2*nn]]]; cp=SelectFirst[prs, CoprimeQ[#, n]&]; m1=cp*Floor[n/cp]; m2=m1+cp; If[n-m1<=m2-n, m1, m2]] (* Harvey P. Dale, Jan 19 2019 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Aug 19 2008
EXTENSIONS
Extended by Ray Chandler, Jun 22 2009
STATUS
approved