OFFSET
1,3
LINKS
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=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