login
a(1) = 1; for n > 1, a(n) = 2 if the concatenation of all the previous terms is prime and a(n) = 1 otherwise.
2

%I #24 Dec 04 2019 03:44:59

%S 1,1,2,1,1,1,2,1,1,2,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,

%T 1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

%U 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

%N a(1) = 1; for n > 1, a(n) = 2 if the concatenation of all the previous terms is prime and a(n) = 1 otherwise.

%C Does this sequence contain an infinite number of 2s?

%H Robert Israel, <a href="/A309059/b309059.txt">Table of n, a(n) for n = 1..10000</a>

%H Sean A. Irvine, <a href="https://github.com/archmageirvine/joeis/blob/master/src/irvine/oeis/a309/A309059.java">Java program</a> (github)

%e For n = 2, the concatenation of the previous terms is 1, which is not prime, so a(2) = 1.

%e For n = 3, the concatenation of the previous terms is 11, which is prime, so a(3) = 2.

%e For n = 4, the concatenation of the previous terms is 112 = 2^4 * 7, which is clearly not prime, so a(4) = 1.

%p A[1]:= 1; x:= 1;

%p for i from 2 to 100 do

%p if isprime(x) then A[i]:= 2; x:= 10*x+2;

%p else A[i]:= 1; x:= 10*x+1

%p fi

%p od:

%p seq(A[i],i=1..100); # _Robert Israel_, Dec 03 2019

%t IntegerDigits[NestList[10# + If[PrimeQ[#], 2, 1] &, 1, 80][[-1]]] (* _Alonso del Arte_, Jul 13 2019 *)

%K nonn,base

%O 1,3

%A _Eric Joseph Brignac_, Jul 09 2019