login
a(1)=1; for n > 1, a(n) = a(n-1) + 1 if n is already in the sequence, a(n) = a(n-1) + 3 otherwise.
15

%I #37 Mar 09 2021 19:13:00

%S 1,4,7,8,11,14,15,16,19,22,23,26,29,30,31,32,35,38,39,42,45,46,47,50,

%T 53,54,57,60,61,62,63,64,67,70,71,74,77,78,79,82,85,86,89,92,93,94,95,

%U 98,101,102,105,108,109,110,113,116,117,120,123,124,125,126

%N a(1)=1; for n > 1, a(n) = a(n-1) + 1 if n is already in the sequence, a(n) = a(n-1) + 3 otherwise.

%C More generally for fixed r, there is a nice connection between the sequence a(1)=1, a(n) = a(n-1) + 1 if n is in the sequence, a(n) = a(n-1) + r + 1 otherwise and the so-called metafibonacci sequences. Indeed, (a(n)-n)/r is a generalized metafibonacci sequence of order r as defined in Ruskey's recent paper (reference given at A046699). - _Benoit Cloitre_, Feb 04 2007

%H Reinhard Zumkeller, <a href="/A080578/b080578.txt">Table of n, a(n) for n = 1..10000</a>

%H B. Cloitre, N. J. A. Sloane and M. J. Vandermast, <a href="http://www.cs.uwaterloo.ca/journals/JIS/VOL6/Cloitre/cloitre2.html">Numerical analogues of Aronson's sequence</a>, J. Integer Seqs., Vol. 6 (2003), #03.2.2.

%H B. Cloitre, N. J. A. Sloane and M. J. Vandermast, <a href="https://arxiv.org/abs/math/0305308">Numerical analogues of Aronson's sequence</a>, arXiv:math/0305308 [math.NT], 2003.

%F a(n) = 2n + O(1); a(2^n) = 2^(n+1). - _Benoit Cloitre_, Oct 12 2003

%F a(1) = 1, for n >= 2 a(n) = a(n + 1 - 2^floor(log(n)/log(2))) + 2*2^floor(log(n)/log(2)) - 1; (a(n) - n)/2 = A046699(n) for n >= 2. - _Benoit Cloitre_, Feb 04 2007

%F a(n) = A055938(n-1) + 2 (conjectured). - _Ralf Stephan_, Dec 27 2013

%t l={1}; a=1; For[n=2, n<=100, If[MemberQ[l, n], a=a+1, a=a+3]; AppendTo[l, a]; n++]; l (* _Indranil Ghosh_, Apr 07 2017 *)

%o (PARI) a(n)=if(n<2,1,a(n+1-2^floor(log(n)/log(2)))+2*2^floor(log(n)/log(2))-1) \\ _Benoit Cloitre_, Feb 04 2007

%o (Haskell)

%o a080578 n = a080578_list !! (n-1)

%o a080578_list = 1 : f 2 [1] where

%o f x zs@(z:_) = y : f (x + 1) (y : zs) where

%o y = if x `elem` zs then z + 1 else z + 3

%o -- _Reinhard Zumkeller_, Sep 26 2014

%o (Python)

%o l=[1]

%o a=1

%o for n in range(2, 101):

%o a += 3 if n not in l else 1

%o l.append(a)

%o print(l) # _Indranil Ghosh_, Apr 07 2017

%Y Cf. A080455, A080456, A080457, A080458, A080036, A080037, A080468.

%K nonn

%O 1,2

%A _N. J. A. Sloane_ and _Benoit Cloitre_, Mar 23 2003