A231475 Largest integer less than 5 and coprime to n.
4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4, 3, 4, 1, 4, 3, 4
Offset: 1
Examples
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.
Links
- Antti Karttunen, Table of n, a(n) for n = 1..65537
- Wikipedia, GCD
Programs
-
Mathematica
Max[Table[If[CoprimeQ[#,d],d,0],{d,4}]]&/@Range[100] (* Harvey P. Dale, Aug 27 2022 *)
-
PARI
A231475(n, m=5) = for(k=1, m, gcd(n, m-k)==1&&return(m-k));
Formula
a(2k+1) = 4 = 2*2.
a(2k) = 1 if 3|k, otherwise a(2k)=3. - Jon Perry, Nov 09 2013