This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A036229 #30 Apr 08 2022 12:39:17 %S A036229 2,11,211,2111,12211,111121,1111211,11221211,111112121,1111111121, %T A036229 11111121121,111111211111,1111111121221,11111111112221, %U A036229 111111112111121,1111111112122111,11111111111112121,111111111111112111,1111111111111111111,11111111111111212121 %N A036229 Smallest n-digit prime containing only digits 1 or 2 or -1 if no such prime exists. %C A036229 It is conjectured that such a prime always exists. %C A036229 a(2), a(19), a(23), etc. are the prime repunits (A004023). a(1000) = (10^n-1)/9 + 111011000010. %H A036229 Chai Wah Wu, <a href="/A036229/b036229.txt">Table of n, a(n) for n = 1..1000</a> (terms n=1..400 from Alois P. Heinz) %H A036229 Robert G. Wilson v, <a href="/A036229/a036229.txt">Comments and first 100 terms</a> %t A036229 Do[p = (10^n - 1)/9; k = 0; While[ ! PrimeQ[p], k++; p = FromDigits[ PadLeft[ IntegerDigits[ k, 2], n] + 1]]; Print[p], {n, 1, 20}] %t A036229 Table[Min[Select[ FromDigits/@Tuples[{1,2},n],PrimeQ]],{n,20}] (* _Harvey P. Dale_, Feb 05 2014 *) %o A036229 (Python) %o A036229 from sympy import isprime %o A036229 def A036229(n): %o A036229 k, r, m = (10**n-1)//9, 2**n-1, 0 %o A036229 while m <= r: %o A036229 t = k+int(bin(m)[2:]) %o A036229 if isprime(t): %o A036229 return t %o A036229 m += 1 %o A036229 return -1 # _Chai Wah Wu_, Aug 18 2021 %Y A036229 Cf. A036937, A068086. %K A036229 nonn,base,nice %O A036229 1,1 %A A036229 _G. L. Honaker, Jr._ %E A036229 Edited by _N. J. A. Sloane_ and _Robert G. Wilson v_, May 03 2002 %E A036229 Escape clause added by _Chai Wah Wu_, Aug 18 2021