login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A284511
a(1) = 1, a(2) = 2, a(3) = 2; a(n) = a(a(n-1)-1) + a(n-a(n-2)) for n > 3.
3
1, 2, 2, 3, 4, 4, 4, 5, 7, 8, 7, 7, 8, 8, 8, 9, 12, 14, 12, 11, 15, 15, 13, 14, 15, 15, 15, 16, 16, 16, 16, 17, 21, 23, 23, 23, 23, 23, 24, 25, 26, 27, 27, 27, 29, 28, 29, 27, 26, 28, 30, 30, 29, 30, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 38, 44, 43, 41, 40, 40, 40, 41, 46, 50
OFFSET
1,2
FORMULA
a(n) = a(a(n-1)-1) + a(n-a(n-2)), with a(1) = 1, a(2) = 2, a(3) = 2.
EXAMPLE
a(4) = 3 because a(4) = a(a(3) - 1) + a(4 - a(2)) = a(1) + a(2) = 3.
MAPLE
a:= proc(n) option remember;
procname(procname(n-1)-1)+procname(n-procname(n-2))
end proc:
a(1):= 1: a(2):= 2: a(3):= 2:
map(a, [$1..100]); # Robert Israel, Mar 28 2017
MATHEMATICA
a[1]=1; a[2]=a[3]=2; a[n_] := a[n] = a[a[n-1]-1] + a[n-a[n-2]]; Array[a, 74] (* Giovanni Resta, Mar 28 2017 *)
PROG
(PARI) a=vector(1000); a[1]=1; a[2]=a[3]=2; for(n=4, #a, a[n]=a[a[n-1]-1]+a[n-a[n-2]]); a
(Sage)
@CachedFunction
def a(n): # A284511
if (n<4): return 2 - bool(n==1)
else: return a(a(n-1)-1) + a(n-a(n-2))
[a(n) for n in (1..80)] # G. C. Greubel, Mar 28 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Altug Alkan, Mar 28 2017
STATUS
approved