OFFSET
1,3
COMMENTS
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (1,0,0,1,-1).
FORMULA
For n >= 3, a(n) = (n+1)/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).
G.f.: t*(1 + t^2 + t^3 - t^4 + 2*t^5 - 2*t^6)/((1-t)*(1-t^4)). - Mamuka Jibladze, Aug 22 2019
MATHEMATICA
cp[n_]:=Module[{k=Ceiling[n/2]}, While[!CoprimeQ[n, k], k++]; k]; Array[cp, 80] (* Harvey P. Dale, Nov 06 2013 *)
PROG
(PARI) a(n) = {if(n%2, (n+1)/2, if(n==2, 1, n/2 + if(n%4, 2, 1)))} \\ Andrew Howroyd, Aug 22 2019
(Python)
def A116922(n): return n+1>>1 if n&1 or n==2 else (n>>1)+(2 if n&2 else 1) # Chai Wah Wu, Jul 31 2024
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Leroy Quet, Feb 26 2006
EXTENSIONS
More terms from Wyatt Lloyd (wal118(AT)psu.edu), Mar 25 2006
STATUS
approved