login
Lexicographically earliest infinite sequence of distinct positive integers such that a(1) = 1 and a(n-1) + a(n) is divisible by the first digit of a(n).
2

%I #21 Feb 22 2022 21:26:01

%S 1,10,2,11,12,3,13,14,7,15,5,16,4,17,18,6,19,21,23,25,27,9,29,31,32,8,

%T 20,22,24,26,28,35,34,38,37,43,41,47,45,30,33,36,39,49,51,54,42,46,59,

%U 56,40,44,48,52,53,57,58,62,64,68,72,60,50,55,65,61,79,75,63,69,71,67,73,74,86,82,98,70

%N Lexicographically earliest infinite sequence of distinct positive integers such that a(1) = 1 and a(n-1) + a(n) is divisible by the first digit of a(n).

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

%C First differs from A323821 at a(32).

%H Carole Dubois, <a href="/A351840/b351840.txt">Table of n, a(n) for n = 1..200</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%e a(1) + a(2) = 1 + 10 = 11 which is divisible by 1 (the first digit of 10);

%e a(2) + a(3) = 10 + 2 = 12 which is divisible by 2 (the first digit of 2);

%e a(3) + a(4) = 2 + 11 = 13 which is divisible by 1 (the first digit of 11);

%e a(4) + a(5) = 11 + 12 = 23 which is divisible by 1 (the first digit of 12);

%e a(5) + a(6) = 12 + 3 = 15 which is divisible by 3 (the first digit of 3); etc.

%t nn = 78; c[_] = 0; a[1] = c[1] = u = 1; Do[While[c[u] != 0, u++]; k = u; While[Nand[c[k] == 0, Mod[a[n - 1] + k, First@ IntegerDigits[k]] == 0], k++]; Set[{a[n], c[k]}, {k, n}], {n, 2, nn}]; Array[a[#] &, nn] (* _Michael De Vlieger_, Feb 21 2022 *)

%o (Python)

%o def aupton(terms):

%o alst, aset, minunused = [1], {1}, 2

%o while len(alst) < terms:

%o an = minunused

%o while an in aset or (alst[-1]+an)%int(str(an)[0]): an += 1

%o alst.append(an); aset.add(an)

%o while minunused in aset: minunused += 1

%o return alst

%o print(aupton(100)) # _Michael S. Branicky_, Feb 21 2022

%Y Cf. A323821.

%K base,nonn

%O 1,2

%A _Eric Angelini_ and _Carole Dubois_, Feb 21 2022