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.

A357142 Nonnegative numbers all of whose pairs of consecutive decimal digits are adjacent digits, where 9 and 0 are considered adjacent.

This page as a plain text file.
%I A357142 #36 Dec 09 2022 23:04:32
%S A357142 0,1,2,3,4,5,6,7,8,9,10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,
%T A357142 90,98,101,109,121,123,210,212,232,234,321,323,343,345,432,434,454,
%U A357142 456,543,545,565,567,654,656,676,678,765,767,787,789,876,878,890,898,901,909
%N A357142 Nonnegative numbers all of whose pairs of consecutive decimal digits are adjacent digits, where 9 and 0 are considered adjacent.
%C A357142 This is very similar to A033075, with the exception of considering 0 and 9 as adjacent digits. This allows these digits to be equal to the other digits, making it a more balanced list.
%p A357142 q:= n-> (l-> andmap(x-> x in {1, 9}, {seq(abs(l[i]-l[i-1]),
%p A357142              i=2..nops(l))}))(convert(n, base, 10)):
%p A357142 select(q, [$0..1000])[];  # _Alois P. Heinz_, Sep 14 2022
%t A357142 q[n_] := AllTrue[Abs @ Differences @ IntegerDigits[n], MemberQ[{1, 9}, #] &]; Select[Range[0, 1000], q] (* _Amiram Eldar_, Sep 15 2022 *)
%o A357142 (Python)
%o A357142 def add_dig(x):
%o A357142   d = (x%10-1)%8 if x%10 != 0 else 1
%o A357142   return 10*x+d
%o A357142 def try_incr(x):
%o A357142   if x < 10: return x+1
%o A357142   r = x//10
%o A357142   d2 = r%10
%o A357142   d = max((d2+1)%10,(d2-1)%10)
%o A357142   return 10*r+d
%o A357142 def incr(x):
%o A357142   new_x=try_incr(x)
%o A357142   return new_x if new_x>x else add_dig(incr(x//10))
%o A357142 x = 0
%o A357142 for n in range(1,1000):
%o A357142   print(f"{n} {x}")
%o A357142   x = incr(x)
%o A357142 (PARI) a(n) = { n--; for (b=0, oo, if (n <= 9*2^b, my (v=ceil(n/2^b), p=(n-1)%(2^b)); while (b>0, v=10*v+vecsort([(v-1)%10, (v+1)%10])[1+bittest(p,b--)];); return (v), n -= 9*2^b)) } \\ _Rémy Sigrist_, Sep 15 2022
%Y A357142 Cf. A032981, A033075, A043089 (ternary analog), A048491.
%K A357142 nonn,base,easy
%O A357142 1,3
%A A357142 _Ofer Zivony_, Sep 14 2022