A385938 a(n) = 2*n/3 if n == 0 (mod 3), (2*n+1)/3 if n == 1 (mod 3), (7*n+1)/3 if n == 2 (mod 3).
0, 1, 5, 2, 3, 12, 4, 5, 19, 6, 7, 26, 8, 9, 33, 10, 11, 40, 12, 13, 47, 14, 15, 54, 16, 17, 61, 18, 19, 68, 20, 21, 75, 22, 23, 82, 24, 25, 89, 26, 27, 96, 28, 29, 103, 30, 31, 110, 32, 33, 117, 34, 35, 124, 36, 37, 131, 38, 39, 138, 40, 41, 145, 42, 43, 152, 44, 45, 159
Offset: 0
Examples
a(0) = 2*0/3 = 0. a(1) = (2*1+1)/3 = 1. a(2) = (7*2+1)/3 = 5. a(3) = 2*3/3 = 2.
Links
- Index entries for linear recurrences with constant coefficients, signature (0,0,2,0,0,-1).
Crossrefs
Programs
-
Mathematica
a[x_] := Which[Mod[x, 3] == 0, 2*x/3, Mod[x, 3] == 1, (2*x + 1)/3, Mod[x, 3] == 2, (7*x + 1)/3]; Table[a[n], {n, 0, 50}]
-
PARI
a(n) = if(n%3==0, 2*n/3, if(n%3==1, (2*n+1)/3, (7*n+1)/3))
-
Python
def A385938(n): q, r = divmod(n,3) return (q<<1)+r if r<2 else 7*q+5 # Chai Wah Wu, Jul 17 2025
Formula
G.f.: x*(1+5*x+2*x^2+x^3+2*x^4) / ( (x-1)^2*(1+x+x^2)^2 ). - R. J. Mathar, Jul 30 2025
Comments