A366197 Lexicographically earliest permutation of the nonnegative integers such that the absolute difference between the digitsum of a(n) and the digitsum of a(n+2) = 1.
0, 1, 10, 2, 11, 3, 12, 4, 13, 5, 14, 6, 15, 7, 16, 8, 17, 9, 18, 19, 26, 27, 25, 28, 24, 29, 23, 37, 22, 36, 21, 35, 20, 34, 30, 33, 31, 32, 41, 40, 42, 50, 43, 51, 44, 52, 45, 53, 46, 54, 38, 55, 39, 47, 49, 48, 57, 56, 58, 64, 59, 63, 67, 62, 66, 61, 65, 60
Offset: 0
Examples
DS stands hereunder for DigitSum: a(0) = 0 (DS 0) and a(2) = 10 (DS 1) and the absolute difference 0 - 1 = 1; a(1) = 1 (DS 1) and a(3) = 2 (DS 2) and the absolute difference 1 - 2 = 1; a(2) = 10 (DS 1) and a(4) = 11 (DS 2) and the absolute difference 1 - 2 = 1; a(3) = 2 (DS 2) and a(5) = 3 (DS 3) and the absolute difference 2 - 3 = 1; a(4) = 11 (DS 2) and a(6) = 12 (DS 3) and the absolute difference 2 - 3 = 1; etc.
Links
- John Tyler Rascoe, Table of n, a(n) for n = 0..10000
Programs
-
Python
from itertools import count, filterfalse def DS(y): z = str(y) return sum(int(z[i]) for i in range (0,len(z))) def A366197_list(n_max): A = [0,1] S = set(A) for n in range(2,n_max+1): for i in filterfalse(S._contains_, count(1)): if abs(DS(A[n-2])-DS(i)) == 1: A.append(i) S.add(i) break return(A) # John Tyler Rascoe, Oct 22 2023
Extensions
More terms from Alois P. Heinz, Oct 03 2023