OFFSET
1,1
COMMENTS
a(1)=1 cannot happen, so the sequence S starts with a(1)=2.
Note that a(n)=a(1)+a(2)+...+a(n-1) can hold even if n is not in S. The smallest example is n=3.
All terms are even. - Reinhard Zumkeller, Nov 06 2013
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..1000
FORMULA
a(2*n) = A145654(n+1). - Reinhard Zumkeller, Nov 06 2013
a(2*n+1) = 2*n+2.
From Colin Barker, Jan 30 2016: (Start)
a(n) = 2*(2^(n/2+1)-2)-n for n even.
a(n) = n+1 for n odd.
a(n) = -a(n-1)+3*a(n-2)+3*a(n-3)-2*a(n-4)-2*a(n-5) for n>5.
G.f.: 2*x*(1+2*x) / ((1-x)*(1+x)^2*(1-2*x^2)). (End)
E.g.f.: (x - 4)*cosh(x) + 4*cosh(sqrt(2)*x) + (1 - x)*sinh(x). - Stefano Spezia, Oct 14 2024
MATHEMATICA
s={2}; Do[If[MemberQ[s, n], m=Total[s], m=n+1]; AppendTo[s, m], {n, 2, 46}]; s (* James C. McMahon, Oct 13 2024 *)
PROG
(Haskell)
a121173 n = a121173_list !! (n-1)
a121173_list = f 1 [] where
f x ys = y : f (x + 1) (y : ys) where
y = if x `elem` ys then sum ys else x + 1
-- Reinhard Zumkeller, Nov 06 2013
(Python)
from itertools import count, islice
def agen(): # generator of terms
S, s, an = {2}, 2, 2
for n in count(2):
yield an
an = s if n in S else n+1
s += an
S.add(an)
print(list(islice(agen(), 50))) # Michael S. Branicky, Oct 13 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Max Alekseyev, Aug 15 2006
STATUS
approved