OFFSET
1,2
LINKS
Altug Alkan, Table of n, a(n) for n = 1..20000
Altug Alkan, Scatterplot of A284511
Altug Alkan, Scatterplot of 2*a(n)-n
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