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”).
%I #22 Aug 21 2019 03:20:01
%S 1,2,5,8,4,7,10,13,16,19,22,11,14,17,20,23,26,29,32,35,38,41,44,47,50,
%T 25,28,31,34,37,40,43,46,49,52,55,58,61,64,67,70,73,76,79,82,85,88,91,
%U 94,97,100,103,106,53,56,59,62,65,68,71,74,77,80,83,86,89,92,95,98,101
%N a(n) is the least number not in the sequence so far and whose absolute difference from a(n-1) is not in the sequence so far, with a(1) = 1 and a(2) = 2.
%C a(n) (mod 3) != 0;
%C a(n) >= n except for n= 5, 12, 26, 54, 110, 222, 446, 894, ...;
%C a(n) < 2n except for n= 4, 11, 25, 53, 109, 221, 445, 893, ...;
%C 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, ..., .
%e 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.
%p b:= proc(n) option remember; n in {1, 2} end:
%p a:= proc(n) option remember; local k, t; if n<3 then n
%p else t:= a(n-1); for k while b(k) or
%p b(abs(k-t)) do od; b(k):= true; k fi
%p end:
%p seq(a(n), n=1..100); # _Alois P. Heinz_, Aug 19 2019
%t 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]
%Y Cf. A001651, A005408.
%K nonn
%O 1,2
%A _Robert G. Wilson v_, Jul 18 2019