OFFSET
0,3
REFERENCES
J. H. Conway and R. K. Guy, The Book of Numbers, Copernicus Press, NY, 1996. Sequence can be seen in the successive circled numbers at the top of page 64.
LINKS
Andrew Howroyd, Table of n, a(n) for n = 0..10000
Index entries for linear recurrences with constant coefficients, signature (0,0,4,0,0,-6,0,0,4,0,0,-1).
FORMULA
a(n) = n if n mod 3 = 0, = ((n+2)/3)^3 if n mod 3 = 1, and otherwise (n+1)^2/3.
G.f.: x*(1 + 3*x + 3*x^2 + 4*x^3 - 6*x^5 + x^6 - 3*x^7 + 3*x^8)/((1 - x)^4*(1 + x + x^2)^4). - Andrew Howroyd, Nov 12 2025
MAPLE
f:=proc(n) if (n mod 3) = 0 then n
elif (n mod 3) = 1 then ((n+2)/3)^3;
else (n+1)^2/3; fi; end;
[seq(f(n), n=0..100)];
MATHEMATICA
A346005[n_] := Switch[Mod[n, 3], 0, n, 1, ((n + 2)/3)^3, _, (n + 1)^2/3];
Array[A346005, 60, 0] (* Paolo Xausa, Nov 13 2025 *)
PROG
(Python)
def A346005(n): return n if n % 3 == 0 else ((n+2)//3)**3 if n % 3 == 1 else (n+1)**2//3 # Chai Wah Wu, Jul 25 2021
(PARI) a(n) = { my(r=n%3); if (r == 0, n, if(r==1, ((n+2)/3)^3, (n+1)^2/3)) } \\ Andrew Howroyd, Nov 12 2025
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
N. J. A. Sloane, Jul 25 2021
STATUS
approved
