login
a(1) = a(2) = a(3) = 1, a(n) = a(a(n-1)) + a(n-a(n-1)) for n >= 4.
(Formerly M0253)
7

%I M0253 #41 Mar 27 2024 08:40:44

%S 1,1,1,2,2,3,3,3,4,5,5,5,5,6,7,7,8,8,8,8,8,9,10,11,11,12,12,12,13,13,

%T 13,13,13,13,14,15,16,16,17,18,18,19,19,19,20,20,20,20,21,21,21,21,21,

%U 21,21,22,23,24,25,25,26,27,27,28

%N a(1) = a(2) = a(3) = 1, a(n) = a(a(n-1)) + a(n-a(n-1)) for n >= 4.

%C a(n) - a(n-1) = 0 or 1 (see the 1991 Monthly reference). - _Emeric Deutsch_, Jun 06 2005

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H T. D. Noe, <a href="/A005350/b005350.txt">Table of n, a(n) for n = 1..1000</a>

%H R. K. Guy, <a href="http://www.jstor.org/stable/2691503">The Second Strong Law of Small Numbers</a>, Math. Mag, 63 (1990), no. 1, 3-20.

%H R. K. Guy, <a href="/A005347/a005347.pdf">The Second Strong Law of Small Numbers</a>, Math. Mag, 63 (1990), no. 1, 3-20. [Annotated scanned copy]

%H R. K. Guy and N. J. A. Sloane, <a href="/A005180/a005180.pdf">Correspondence</a>, 1988.

%H D. Kleitman, <a href="http://www.jstor.org/stable/2324158">Solution to Problem E3274</a>, Amer. Math. Monthly, 98 (1991), 958-959.

%p A005350 := proc(n) option remember; if n<=3 then 1 else procname(procname(n-1)) + procname(n-procname(n-1)); end if; end proc:

%p seq(A005350(n),n=1..64) ;

%t a[1] = a[2] = a[3] = 1; a[n_] := a[n] = a[a[n-1]] + a[n-a[n-1]]; Table[a[n], {n, 1, 64}] (* _Jean-François Alcover_, Feb 11 2014 *)

%o (Haskell)

%o a005350 n = a005350_list !! (n-1)

%o a005350_list = 1 : 1 : 1 : h 4 1 where

%o h x y = z : h (x + 1) z where z = a005350 y + a005350 (x - y)

%o -- _Reinhard Zumkeller_, Jul 20 2012

%o (SageMath)

%o @CachedFunction

%o def a(n): return 1 if (n<4) else a(a(n-1)) + a(n-a(n-1))

%o [a(n) for n in range(1,100)] # _G. C. Greubel_, Nov 14 2022

%Y Cf. A004001, A005185, A005707.

%K nonn,easy,nice

%O 1,4

%A _N. J. A. Sloane_, _R. K. Guy_