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”).

A286449
Restricted growth sequence computed for A033879 (deficiency), or equally, for A033880 (abundance of n).
15
1, 1, 2, 1, 3, 4, 5, 1, 6, 2, 7, 8, 9, 3, 5, 1, 10, 11, 12, 13, 7, 14, 15, 16, 17, 7, 18, 4, 19, 16, 20, 1, 12, 18, 15, 21, 22, 10, 15, 23, 24, 16, 25, 3, 9, 26, 27, 28, 29, 30, 20, 5, 31, 16, 32, 33, 34, 35, 36, 37, 38, 19, 15, 1, 27, 16, 39, 7, 25, 8, 40, 41, 42, 34, 35, 9, 36, 16, 43, 44, 29, 32, 45, 46, 47, 24, 48, 8, 49, 50, 40, 10, 36, 51, 40, 52, 53
OFFSET
1,3
EXAMPLE
We start by setting a(1) = 1 for A033879(1) = 1. Then, whenever A033879(k) is equal to some A033879(m) with m < k, we set a(k) = a(m). Otherwise (when the value is a new one, not encountered before), we allot for a(k) the least natural number not present among a(1) .. a(k-1).
For n=2, as A033879(2) = 1, which was already present at A033879(1), we set a(2) = a(1) = 1.
For n=3, as A033879(3) = 2, which is a new value not encountered before, we set a(3) = 1 + max(a(1),a(2)) = 2.
For n=4, as A033879(4) = 1, which was already present at n = 2 and n = 1, we set a(4) = a(1) = 1.
For n=5, as A033879(5) = 4, which is a new value not encountered before, we set a(5) = 1 + max(a(1),a(2),a(3),a(4)) = 3.
For n=12, as A033879(12) = -4, which is a new value not encountered before, we set a(12) = 1 + max(a(1),...,a(11)) = 8. Note that the sign matters here; -4 is not equal to +4, which was encountered already at n=5.
PROG
(PARI)
rgs_transform(invec) = { my(occurrences = Map(), outvec = vector(length(invec)), u=1); for(i=1, length(invec), if(mapisdefined(occurrences, invec[i]), my(pp = mapget(occurrences, invec[i])); outvec[i] = outvec[pp] , mapput(occurrences, invec[i], i); outvec[i] = u; u++ )); outvec; };
write_to_bfile(start_offset, vec, bfilename) = { for(n=1, length(vec), write(bfilename, (n+start_offset)-1, " ", vec[n])); }
A033879(n) = ((2*n)-sigma(n));
write_to_bfile(1, rgs_transform(vector(10000, n, A033879(n))), "b286449.txt");
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, May 13 2017
STATUS
approved