%I #12 May 31 2017 22:45:09
%S 101,12101,32321,210101,432121,1012321,1212121,3210101,3210121,
%T 3212101,3232321,3432101,5432321,5434321,21212101,21232121,23210101,
%U 23232101,43432321,45434321,101012321,101210101,101232121,121232101,123210121,123232121,321012121
%N Terms in A048398 ending with 1.
%C Among first 114956 terms, number of n-digit terms are: 0, 0, 1, 0, 2, 2, 9, 6, 22, 23, 32, 57, 166, 246, 382, 572, 1770, 2936, 3956, 6183, 18132, 30818, 49641.
%H Chai Wah Wu, <a href="/A185893/b185893.txt">Table of n, a(n) for n = 1..10000</a>
%t Select[Prime[Range[100000]], IntegerDigits[#][[-1]] == 1 && Union[Abs[Differences[IntegerDigits[#]]]] == {1} &]
%o (Python 3.2 or higher)
%o from itertools import product, accumulate
%o from sympy import isprime
%o A185893_list = []
%o for l in range(1,19):
%o dlist = [1]*l
%o for elist in product([-1,1],repeat=l):
%o flist = [str(d+e) for d,e in zip(dlist,accumulate(elist)) if 0 <= d+e < 10]
%o if len(flist) == l and flist[-1] != '0':
%o n = 10*int(''.join(flist[::-1])) + 1
%o if isprime(n):
%o A185893_list.append(n)
%o A185893_list = sorted(A185893_list) # _Chai Wah Wu_, May 31 2017
%Y Cf. A048398, A182781.
%K nonn,base
%O 1,1
%A _Zak Seidov_, Feb 05 2011
|