login
Lexicographically earliest permutation of the composite numbers such that a(n) - [the next digit] is a prime number.
2

%I #11 Sep 25 2023 08:49:35

%S 4,10,8,6,12,9,20,14,15,21,22,30,16,32,18,50,33,24,51,40,34,35,42,52,

%T 54,70,36,55,25,26,38,72,56,39,27,44,74,75,28,57,45,46,58,500,90,76,

%U 91,80,77,48,78,501,200,92,93,49,60,100,300,700,94,502,301,81,82,95,62,96,702,102,104,105,84,106,98,99,201,85,63,202,302,900

%N Lexicographically earliest permutation of the composite numbers such that a(n) - [the next digit] is a prime number.

%C Is this sequence finite?

%C Yes, the sequence is finite. The last term is 900 as the previous prime before 900 is 887 and so the first digit of any next term is too small to reach 887. - _David A. Corneth_, Sep 18 2023

%e a(1) = 4 and 4 - 1 = 3 (prime);

%e a(2) = 10 and 10 - 8 = 2 (prime);

%e a(3) = 8 and 8 - 6 = 2 (prime);

%e a(4) = 6 and 6 - 1 = 5 (prime);

%e a(5) = 12 and 12 - 9 = 3 (prime); etc.

%o (PARI) sequence() = {my(res = List([4]), n = 900, leftover = vector(n, i, 1), proceed = 1); leftover[1] = 0; leftover[4] = 0; forprime(p = 2, n, leftover[p] = 0); while(proceed, for(i = 1, n, if(leftover[i] && isprime(res[#res] - digits(i)[1]), listput(res, i); leftover[i] = 0; next(2))); proceed = 0); res} \\ _David A. Corneth_, Sep 18 2023

%Y Cf. A365768, A365769, A365780.

%K nonn,easy,base,fini,full

%O 1,1

%A _Eric Angelini_, Sep 18 2023

%E More terms from _David A. Corneth_, Sep 18 2023