OFFSET
1,2
COMMENTS
a(n) (mod 3) != 0;
a(n) >= n except for n= 5, 12, 26, 54, 110, 222, 446, 894, ...;
a(n) < 2n except for n= 4, 11, 25, 53, 109, 221, 445, 893, ...;
First occurrence of k or 0 if impossible: 1, 2, 0, 5, 3, 0, 6, 4, 0, 7, 12, 0, 8, 13, 0, 9, 14, 0, 10, 15, 0, 11, 16, 0, 26, 17, 0, 27, 18, 0, ..., .
EXAMPLE
a(3) cannot be 3 since 3-2 = 1 which is a(1), it cannot be 4 since 4-2 = 2 which is a(2), but a(3) can be 5.
MAPLE
b:= proc(n) option remember; n in {1, 2} end:
a:= proc(n) option remember; local k, t; if n<3 then n
else t:= a(n-1); for k while b(k) or
b(abs(k-t)) do od; b(k):= true; k fi
end:
seq(a(n), n=1..100); # Alois P. Heinz, Aug 19 2019
MATHEMATICA
a[n_] := a[n] = Block[{b = a[n -1], k = 3, s = Array[a, n -1]}, While[ MemberQ[s, k] || MemberQ[s, Abs[b -k]], k++]; k]; a[1] = 1; a[2] = 2; Array[a, 70]
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert G. Wilson v, Jul 18 2019
STATUS
approved