%I #12 Feb 12 2023 12:30:11
%S 1,2,6,4,3,7,16,8,9,14,13,17,12,10,20,11,19,15,18,24,5,25,21,22,26,27,
%T 23,34,28,29,32,31,33,37,35,36,42,30,40,38,39,48,43,44,46,45,47,41,49,
%U 50,51,52,53,54,55,59,58,56,57,60,62,61,66,64,63,67,69,68,65,80,74,71,72,73,77,76,70,75,79,78,84,83,81,82,86,87,95,96,92
%N Lexicographic first sequence of positive integers such that a(n)*a(n+1) has a digit 2, and no term occurs twice.
%C A permutation of the positive integers.
%H Robert Israel, <a href="/A299402/b299402.txt">Table of n, a(n) for n = 1..10000</a>
%e a(1) = 1 is the least positive integer, it has no other requirement to satisfy.
%e a(2) = 2 is the least positive integer > a(1) = 1, and a(2)*a(1) = 2 has a digit 2.
%e a(3) = 6 is the least positive integer > a(2) = 2 such that a(3)*a(2) (= 12) has a digit 2: The smaller choices 3, 4 or 5 do not satisfy this.
%e a(4) = 4 is the least positive integer > a(2) = 2 such that a(4)*a(3) (= 24) has a digit 2: The smaller choice 3 yields 3*6 = 18 and does not satisfy this.
%e Now, the least available positive integer a(5) = 3 is such that 3*4 = 12, which has again a digit 2. And so on.
%p N:= 100: # to get a(1)..a(n) where a(n+1) > N
%p S:= [$2..N]: nS:= N-1:
%p R:= 1: x:= 1; found:= true;
%p while found do
%p found:= false;
%p for i from 1 to nS do
%p if member(2, convert(S[i]*x,base,10)) then
%p found:= true;
%p x:= S[i];
%p R:= R,x;
%p S:= subsop(i=NULL,S);
%p nS:= nS-1;
%p break
%p fi
%p od
%p od:
%p R; # _Robert Israel_, Feb 12 2023
%o (PARI) a(n,f=1,d=2,a=1,u=[a])={for(n=2,n,f&&if(f==1,print1(a","),write(f,n-1," "a));for(k=u[1]+1,oo,setsearch(u,k)&&next;setsearch(Set(digits(a*k)),d)&&(a=k)&&break);u=setunion(u,[a]);while(#u>1&&u[2]==u[1]+1,u=u[^1]));a}
%Y Cf. A299403, A298974, ..., A298979 (analog with digit 3, ..., 9).
%Y Cf. A299957, A299969, ..., A299988 (analog with addition instead of multiplication, and different digits).
%K nonn,base
%O 1,2
%A _M. F. Hasler_, Feb 22 2018
|