%I #28 Jan 16 2023 15:02:55
%S 1,12,122,1224,12242,122424,1224242,12242424,122424244,1224242444,
%T 12242424442,122424244424,1224242444242,12242424442424,
%U 122424244424244,1224242444242444,12242424442424442,122424244424244424
%N a(n) is the least n-digit number whose k-th digit is prime if k is prime, composite if k is composite, and 1 if k=1.
%H Alvin Hoover Belt, <a href="/A113574/b113574.txt">Table of n, a(n) for n = 1..75</a>
%F a(n+1) = a(n)||2 if n+1 is prime, otherwise a(n+1) = a(n)||4 where || is concatenation.
%t nxt[{n_,a_}]:={n+1,If[PrimeQ[n+1],10a+2,10a+4]}; NestList[nxt,{1,1},20][[All,2]] (* _Harvey P. Dale_, Jan 16 2023 *)
%o (Python)
%o from sympy import isprime
%o def a(n): return 1 if n<2 else int(str(a(n - 1)) + "2") if isprime(n) else int(str(a(n - 1)) + "4")
%o print([a(n) for n in range(1, 51)]) # _Indranil Ghosh_, Apr 12 2017
%K base,easy,nonn
%O 1,2
%A _Amarnath Murthy_, Nov 06 2005
%E Corrected and extended by _Alvin Hoover Belt_, Mar 24 2008
%E Name edited by _Jon E. Schoenfield_, Mar 20 2021