A374504 Lexicographically earliest sequence of distinct nonnegative terms such that the absolute difference between the rightmost digit of a(n) and the leftmost digit of a(n+1) is the largest possible one.
0, 9, 1, 90, 91, 92, 93, 94, 95, 10, 96, 11, 97, 12, 98, 13, 99, 14, 900, 901, 902, 903, 904, 905, 15, 16, 17, 18, 19, 100, 906, 101, 907, 102, 908, 103, 909, 104, 910, 911, 912, 913, 914, 915, 105, 106, 107, 108, 109, 110, 916, 111, 917, 112, 918, 113, 919, 114, 920, 921, 922, 923, 924, 925, 115, 116, 117, 118, 119
Offset: 1
Examples
The digits touching the 1st comma (0 and 9) have an absolute difference of 9; The digits touching the 2nd comma (9 and 1) have an absolute difference of 8; The digits touching the 3rd comma (1 and 9) have an absolute difference of 8; The digits touching the 4th comma (0 and 9) have an absolute difference of 9; The digits touching the 5th comma (1 and 9) have an absolute difference of 8; The digits touching the 6th comma (2 and 9) have an absolute difference of 7; The digits touching the 7th comma (3 and 9) have an absolute difference of 6; The digits touching the 8th comma (4 and 9) have an absolute difference of 5; The digits touching the 9th comma (5 and 1) have an absolute difference of 4; from now on, the absolute differences enter into a loop.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..10000
Programs
-
Python
from itertools import islice def gen(d): # generator of terms that start with d pow10 = 1 while True: for i in range(d*pow10, (d+1)*pow10): yield i pow10 *= 10 def agen(): # generator of terms an, g1, g9 = 0, gen(1), gen(9) next1, next9 = next(g1), next(g9) while True: yield an rightmost = an%10 if rightmost > 5 or (rightmost == 5 and next1 < next9): an, next1 = next1, next(g1) else: an, next9 = next9, next(g9) print(list(islice(agen(), 70))) # Michael S. Branicky, Jul 13 2024
Comments