login
Vertically symmetric numbers.
12

%I #14 Jul 09 2022 11:06:09

%S 0,1,8,11,25,52,88,101,111,181,205,215,285,502,512,582,808,818,888,

%T 1001,1111,1251,1521,1881,2005,2115,2255,2525,2885,5002,5112,5252,

%U 5522,5882,8008,8118,8258,8528,8888,10001,10101,10801,11011,11111,11811

%N Vertically symmetric numbers.

%C Numbers that are symmetric about a vertical mirror.

%C 2 and 5 are taken as mirror images (as on calculator displays).

%H Michael S. Branicky, <a href="/A053701/b053701.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..2500 from Nathaniel Johnston)

%p compdig := proc(n) if(n=2)then return 5: elif(n=5)then return 2: elif(n=0 or n=1 or n=8)then return n: else return -1: fi: end: isA053701 := proc(n) local d,l,j: d:=convert(n,base,10): l:=nops(d): for j from 1 to ceil(l/2) do if(not d[j]=compdig(d[l-j+1]))then return false: fi: od: return true: end: for n from 0 to 10000 do if(isA053701(n))then printf("%d, ",n): fi: od: # _Nathaniel Johnston_, May 17 2011

%o (Python)

%o from itertools import count, islice, product

%o def lr(s): return s[::-1].translate({ord('2'):ord('5'), ord('5'):ord('2')})

%o def A053701gen(): # generator of terms

%o yield from [0, 1, 8]

%o for d in count(2):

%o for first in "1258":

%o for rest in product("01258", repeat=d//2-1):

%o left = first + "".join(rest)

%o for mid in [[""], ["0", "1", "8"]][d%2]:

%o yield int(left + mid + lr(left))

%o print(list(islice(A053701gen(), 45))) # _Michael S. Branicky_, Jul 09 2022

%Y Cf. A000787, A007284, A018846 (strobogrammatic numbers).

%K nonn,base

%O 1,3

%A _Henry Bottomley_, Feb 14 2000

%E More terms from Larry Reeves (larryr(AT)acm.org), Oct 01 2001