login
Lexicographically earliest sequence of positive distinct terms such that the a(n)th digit of the sequence is nonprime (see the Comments section).
2

%I #34 Nov 23 2023 10:44:56

%S 1,3,4,6,7,8,9,10,11,12,14,15,16,18,19,20,21,22,23,25,27,38,40,41,37,

%T 39,45,46,48,49,50,51,52,53,55,57,66,67,68,70,71,73,75,80,81,82,83,84,

%U 86,88,89,90,91,92,93,94,95,96,97,98,99,100,102,104,105,106

%N Lexicographically earliest sequence of positive distinct terms such that the a(n)th digit of the sequence is nonprime (see the Comments section).

%C "Nonprime" digits are 0, 1, 4, 6, 8 and 9.

%H David Consiglio, Jr., <a href="/A114316/b114316.txt">Table of n, a(n) for n = 1..1000</a>

%e Nonprime digits are between brackets:

%e Sequence: (1),3,(4),(6),7,(8),(9),(1)(0),(1)(1),(1)2,(1)4, ...

%e Digit position in the sequence: 1st, 3rd, 4th, 6th, 7th, 8th, 9th, 10th, 11th, 12th, 14th, ... = a reordering of the sequence itself.

%o (Python)

%o nonprime = [0,1,4,6,8,9]

%o terms = [1, 3, 4, 6, 7, 8, 9]

%o def si(test_list):#all terms greater than 0 and no repetitions

%o a = all(i > 0 for i in test_list)

%o b = len(test_list) == len(set(test_list))

%o return a & b

%o def clear(test_list):#sequence meets definitional criteria

%o full = (''.join(str(x) for x in test_list))

%o for a in test_list:

%o if int(a)-1 >= len(full):

%o return True

%o elif int(full[int(a)-1]) not in nonprime:

%o return False

%o return True

%o while len(terms) < 1000:

%o start = 1

%o while True:

%o terms.append(start)

%o if si(terms) and clear(terms):

%o break

%o else:

%o terms.pop()

%o start += 1

%o # _David Consiglio, Jr._, Oct 30 2023

%Y Cf. A114319 (same idea but with the "noncomposite" digits 0, 1, 2, 3, 5 and 7).

%K nonn,base

%O 1,2

%A _Eric Angelini_, Feb 05 2006

%E Corrected and extended by _R. J. Mathar_, _Bernard Schott_ and _Eric Angelini_

%E a(63) and beyond from _David Consiglio, Jr._, Oct 30 2023