login
Lexicographically first sequence of different positive terms starting with a(1) = 1, such that a(n+1) is obtained by subtracting or adding to a(n) a term already in the sequence. This term can be subtracted only once and added only once.
1

%I #6 Aug 27 2018 08:15:26

%S 1,2,4,3,6,10,7,5,11,16,9,18,8,15,23,12,22,13,24,19,31,25,17,30,14,28,

%T 43,20,36,21,38,26,44,27,46,32,52,33,29,50,37,59,34,57,35,60,39,63,45,

%U 71,40,67,41,69,42,72,48,77,47,78,49,81,53,86,51,85,65,100,54,90,56,93,55,94,58,96,64,104,61,102,62,105,66

%N Lexicographically first sequence of different positive terms starting with a(1) = 1, such that a(n+1) is obtained by subtracting or adding to a(n) a term already in the sequence. This term can be subtracted only once and added only once.

%C This sequence is a derangement of the positive integers.

%H Jean-Marc Falcoz, <a href="/A318452/b318452.txt">Table of n, a(n) for n = 1..10001</a>

%e The sequence starts with 1,2,4,3,6,10,7,...

%e As all the terms of the sequence must be > 0, we cannot subtract 1 from term 1; thus a(2) is 1 (the last term) + the term a(1) = 1 + 1 = 2;

%e as we cannot add twice the same term, a(3) must be 2 (the last term) + a(2) = 2 + 2 = 4;

%e as the sequence must be the lexicographically first of its kind, and because all terms of the sequence must be different, we subtract the term a(1) = 1 from 4 (the last term) getting 3;

%e as we cannot subtract twice the same term, a(5) must be 3 (the last term) + the term a(4) = 3 + 3 = 6;

%e as the only available term for an addition to the last term a(5) is a(2) = 4, we have a(6) = 6 + 4 = 10;

%e as the sequence must be the lexicographically first of its kind, and because all terms of the sequence must be different, we subtract the term a(4) = 3 from 10 (the last term), getting 7;

%e etc.

%K base,nonn

%O 1,2

%A _Eric Angelini_ and _Jean-Marc Falcoz_, Aug 26 2018