

A116921


a(n) = largest integer <= n/2 which is coprime to n.


2



0, 1, 1, 1, 2, 1, 3, 3, 4, 3, 5, 5, 6, 5, 7, 7, 8, 7, 9, 9, 10, 9, 11, 11, 12, 11, 13, 13, 14, 13, 15, 15, 16, 15, 17, 17, 18, 17, 19, 19, 20, 19, 21, 21, 22, 21, 23, 23, 24, 23, 25, 25, 26, 25, 27, 27, 28, 27, 29, 29, 30, 29, 31, 31, 32, 31, 33, 33, 34, 33, 35, 35, 36, 35, 37, 37
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,5


COMMENTS

a(n) + A116922(n) = n. For n>= 3, A116922(n)  a(n) is 1 if n is odd, is 2 if n is a multiple of 4 and is 4 if n is congruent to 2 (mod 4).
The arithmetic function v+(n,2) as defined in A290988.  Robert Price, Aug 22 2017


LINKS

Table of n, a(n) for n=1..76.
Index entries for linear recurrences with constant coefficients, signature (1,0,0,1,1).


FORMULA

For n >= 3, a(n) = (n1)/2 if n is odd, a(n) = n/2  1 if n is a multiple of 4 and a(n) = n/2  2 if n is congruent to 2 (mod 4).
a(n) = (2*n42*(1)^n+(1)^(n/2)+(1)^(3*n/2))/4, n>2.  Wesley Ivan Hurt, May 26 2015
For n > 2, a(n) = (n2+cos(n*Pi/2)cos(n*Pi))/2.  Wesley Ivan Hurt, Oct 02 2017
G.f.: t^2*(1+t^32*t^4+2*t^5)/((1t)*(1t^4)).  Mamuka Jibladze, Aug 22 2019


MATHEMATICA

Join[{0, 1}, Table[(2 n  4  2 (1)^n + (1)^(n/2) + (1)^(3 n/2))/4, {n, 3, 50}]] (* Wesley Ivan Hurt, May 26 2015 *)
Table[Which[OddQ[n], (n1)/2, Divisible[n, 4], n/21, Mod[n, 4]==2, n/22], {n, 80}]//Abs (* Harvey P. Dale, Jun 24 2017 *)


PROG

(Magma) [0] cat [(2*n42*(1)^n+(1)^(n div 2)+(1)^(3*n div 2)) div 4: n in [3..80]]; // Vincenzo Librandi, May 26 2015
(PARI) a(n) = {forstep(k = n\2, 0, 1, if (gcd(n, k) == 1, return (k)); ); } \\ Michel Marcus, May 26 2015
(PARI) a(n) = {if(n%2, (n1)/2, if(n==2, 1, n/2  if(n%4, 2, 1)))} \\ Andrew Howroyd, Aug 22 2019


CROSSREFS

Cf. A116922, A290988.
Sequence in context: A328518 A163281 A307857 * A173989 A093068 A097357
Adjacent sequences: A116918 A116919 A116920 * A116922 A116923 A116924


KEYWORD

easy,nonn


AUTHOR

Leroy Quet, Feb 26 2006


EXTENSIONS

More terms from Wyatt Lloyd (wal118(AT)psu.edu), Mar 25 2006


STATUS

approved



