A064429 a(n) = floor(n / 3) * 3 + sign(n mod 3) * (3 - n mod 3).
0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10, 12, 14, 13, 15, 17, 16, 18, 20, 19, 21, 23, 22, 24, 26, 25, 27, 29, 28, 30, 32, 31, 33, 35, 34, 36, 38, 37, 39, 41, 40, 42, 44, 43, 45, 47, 46, 48, 50, 49, 51, 53, 52, 54, 56, 55, 57, 59, 58, 60, 62, 61, 63, 65, 64, 66, 68, 67, 69, 71, 70
Offset: 0
Examples
From _Franck Maminirina Ramaharo_, Jul 27 2018: (Start) Interleave 3 sequences: A008585: 0.....3.....6.....9.......12.......15........ A016789: ..2.....5.....8.....11.......14.......17..... A016777: ....1.....4.....7......10.......13.......16.. (End)
Links
- Muniru A Asiru, Table of n, a(n) for n = 0..3000
- Eric Weisstein's World of Mathematics, Alternating Permutations.
- Index entries for linear recurrences with constant coefficients, signature (1,0,1,-1).
- Index entries for sequences that are permutations of the natural numbers.
Programs
-
GAP
a:=[0,2,1,3];; for n in [5..100] do a[n]:=a[n-1]+a[n-3]-a[n-4]; od; a; # Muniru A Asiru, Jul 27 2018
-
Magma
[2*n - 3 - 3*((n-2) div 3): n in [0..80]]; // Vincenzo Librandi, Aug 05 2018
-
Maple
A064429:=n->2*n-3-3*floor((n-2)/3): seq(A064429(n), n=0..100); # Wesley Ivan Hurt, Nov 30 2013
-
Mathematica
Table[2 n - 3 - 3 Floor[(n - 2)/3], {n, 0, 100}] (* Wesley Ivan Hurt, Nov 30 2013 *) {#+1,#-1,#}[[Mod[#,3,1]]]&/@Range[0, 100] (* Federico Provvedi, May 11 2021 *) LinearRecurrence[{1,0,1,-1},{0,2,1,3},80] (* or *) {#[[1]],#[[3]],#[[2]]}&/@Partition[Range[0,80],3]//Flatten (* Harvey P. Dale, Mar 28 2025 *)
-
PARI
a(n) = 2*n-3-3*((n-2)\3); \\ Altug Alkan, Oct 06 2017
Formula
a(n) = A080782(n+1) - 1.
a(n) = n - 2*sin(4*Pi*n/3)/sqrt(3). - Jaume Oliver Lafont, Dec 05 2008
a(n) = lod_3(A080425(n)). - Philippe Deléham, Apr 26 2009
G.f.: x*(2 - x + 2*x^2)/((1 + x + x^2)*(1 - x)^2 ). - R. J. Mathar, Feb 20 2011
a(n) = 2*n - 3 - 3*floor((n-2)/3). - Wesley Ivan Hurt, Nov 30 2013
a(n) = a(n-1) + a(n-3) - a(n-4) for n > 3. - Wesley Ivan Hurt, Oct 06 2017
E.g.f.: x*exp(x) + (2*sin((sqrt(3)*x)/2))/(exp(x/2)*sqrt(3)). - Franck Maminirina Ramaharo, Jul 27 2018
From Guenther Schrack, Feb 05 2020: (Start)
a(n) = a(n-3) + 3 with a(0)=0, a(1)=2, a(2)=1 for n > 2;
a(n) = n + (w^(2*n) - w^n)*(1 + 2*w)/3 where w = (-1 + sqrt(-3))/2. (End)
Sum_{n>=1} (-1)^n/a(n) = log(2)/3. - Amiram Eldar, Jan 31 2023
Comments