OFFSET
1,2
EXAMPLE
a(9) = a(8) - a(7) = 3-2 = 1. The number of occurrences of 1 up to that point is 4, so a(10) = 4.
PROG
(PARI) a=[1, 2]; for(n=2, 99, a=concat(a, if(a[n]>a[n-1], a[n]-a[n-1], sum(i=1, n, a[i]==a[n])))); a \\ M. F. Hasler, May 22 2020, brackets fixed by David A. Corneth, May 22 2020
(PARI) first(n) = {n = max(n, 2); res = vector(n); freqs = vector(2); res[1] = 1; res[2] = 2; freqs[1] = 1; freqs[2] = 1; for(i = 3, n, d = res[i-1] - res[i-2]; if(d > 0, res[i] = d; freqs[d]++ , fr = freqs[res[i-1]]; res[i] = fr; if(fr > #freqs, freqs = concat(freqs, vector(fr - #freqs)); ); freqs[fr]++ ) ); res } \\ David A. Corneth, May 22 2020
CROSSREFS
KEYWORD
AUTHOR
Ali Sada, May 04 2020
STATUS
approved