%I #43 Mar 17 2024 11:40:18
%S 3,2,1,3,5,4,3,8,7,3,11,10,3,14,13,3,17,16,3,20,19,3,23,22,3,26,25,3,
%T 29,28,3,32,31,3,35,34,3,38,37,3,41,40,3,44,43,3,47,46,3,50,49,3,53,
%U 52,3,56,55,3,59,58,3,62,61,3,65,64,3,68,67,3,71,70,3,74,73,3,77,76,3,80
%N a(1)=3, a(2)=2, a(3)=1; thereafter a(n) = a(n-a(n-1)) + a(n-a(n-2)).
%C Similar to Hofstadter's Q-sequence A005185 but with different starting values.
%C Golomb describes this as "quasi-periodic sequence with a quasi-period of 3".
%D Higham, J.; Tanny, S. More well-behaved meta-Fibonacci sequences. Proceedings of the Twenty-fourth Southeastern International Conference on Combinatorics, Graph Theory, and Computing (Boca Raton, FL, 1993). Congr. Numer. 98(1993), 3-17.
%H Reinhard Zumkeller, <a href="/A244477/b244477.txt">Table of n, a(n) for n = 1..10000</a>
%H Altug Alkan, Nathan Fox, and Orhan Ozgur Aybar, <a href="https://doi.org/10.1155/2017/2614163">On Hofstadter Heart Sequences</a>, Complexity, Volume 2017, Article ID 2614163, 8 pages.
%H Nathan Fox, <a href="https://vimeo.com/141111990">Linear-Recurrent Solutions to Meta-Fibonacci Recurrences, Part 1 (video)</a>, Rutgers Experimental Math Seminar, Oct 01 2015. Part 2 is vimeo.com/141111991.
%H S. W. Golomb, <a href="/A005185/a005185_1.pdf">Discrete chaos: sequences satisfying "strange" recursions</a>, unpublished manuscript, circa 1990 [cached copy, with permission (annotated)]
%H <a href="/index/Ho#Hofstadter">Index entries for Hofstadter-type sequences</a>
%H <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (0, 0, 2, 0, 0, -1).
%F From _Colin Barker_, Nov 23 2015: (Start)
%F a(n) = 2*a(n-3) - a(n-6) for n>6.
%F G.f.: x*(2*x^5 + x^4 - 3*x^3 + x^2 + 2*x + 3)/((x - 1)^2*(x^2 + x + 1)^2). (End)
%F a(3*k) = 3*k-2, a(3*k+1) = 3, a(3*k+2) = 3*k+2. - _Nathan Fox_, Apr 02 2017
%F a(n) = 3*(m-1)^2*floor(n/3) - (3*m^2-8*m+2), where m = n mod 3. - _Luce ETIENNE_, Oct 17 2018
%p f := proc(n) option remember;
%p if n<=3 then
%p 4-n
%p elif n > procname(n-1) and n > procname(n-2) then
%p RETURN(procname(n-procname(n-1))+procname(n-procname(n-2)));
%p else
%p ERROR(" died at n= ", n);
%p fi;
%p end proc;
%p [seq(f(n),n=0..200)];
%t a[1] = 3; a[2] = 2; a[3] = 1; a[n_] := a[n] = a[n - a[n - 1]] + a[n - a[n - 2]]; Array[a, 75] (* or *)
%t Flatten@ Table[{Mod[3n, 3] +3, 3n -1, 3n -2}, {n, 25}] (* _Robert G. Wilson v_, Nov 23 2015 *)
%o (Haskell)
%o a244477 n = a244477_list !! (n-1)
%o a244477_list = 3 : 2 : 1 : zipWith (+)
%o (map a244477 $ zipWith (-) [4..] $ tail a244477_list)
%o (map a244477 $ zipWith (-) [4..] $ drop 2 a244477_list)
%o -- _Reinhard Zumkeller_, Jul 05 2014
%o (Magma) [n le 3 select 4-n else Self(n-Self(n-1)) + Self(n-Self(n-2)): n in [1..80]]; // _Vincenzo Librandi_, Nov 24 2015
%Y Cf. A005185.
%Y Cf. A010872.
%K nonn,easy
%O 1,1
%A _N. J. A. Sloane_, Jul 02 2014