cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A366197 #22 Oct 23 2023 02:23:04
%S A366197 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,
%T A366197 23,37,22,36,21,35,20,34,30,33,31,32,41,40,42,50,43,51,44,52,45,53,46,
%U A366197 54,38,55,39,47,49,48,57,56,58,64,59,63,67,62,66,61,65,60
%N 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.
%H A366197 John Tyler Rascoe, <a href="/A366197/b366197.txt">Table of n, a(n) for n = 0..10000</a>
%e A366197 DS stands hereunder for DigitSum:
%e A366197 a(0) =  0 (DS 0) and a(2) = 10 (DS 1) and the absolute difference 0 - 1 = 1;
%e A366197 a(1) =  1 (DS 1) and a(3) =  2 (DS 2) and the absolute difference 1 - 2 = 1;
%e A366197 a(2) = 10 (DS 1) and a(4) = 11 (DS 2) and the absolute difference 1 - 2 = 1;
%e A366197 a(3) =  2 (DS 2) and a(5) =  3 (DS 3) and the absolute difference 2 - 3 = 1;
%e A366197 a(4) = 11 (DS 2) and a(6) = 12 (DS 3) and the absolute difference 2 - 3 = 1; etc.
%o A366197 (Python)
%o A366197 from itertools import count, filterfalse
%o A366197 def DS(y):
%o A366197     z = str(y)
%o A366197     return sum(int(z[i]) for i in range (0,len(z)))
%o A366197 def A366197_list(n_max):
%o A366197     A = [0,1]
%o A366197     S = set(A)
%o A366197     for n in range(2,n_max+1):
%o A366197         for i in filterfalse(S.__contains__, count(1)):
%o A366197             if abs(DS(A[n-2])-DS(i)) == 1:
%o A366197                 A.append(i)
%o A366197                 S.add(i)
%o A366197                 break
%o A366197     return(A) # _John Tyler Rascoe_, Oct 22 2023
%Y A366197 Cf. A007953, A108971, A318486.
%K A366197 base,nonn
%O A366197 0,3
%A A366197 _Eric Angelini_, Oct 03 2023
%E A366197 More terms from _Alois P. Heinz_, Oct 03 2023