A168586 Smallest n-digit prime with only digits 0 and 1, and having least digit sum (or 0, if no such prime exists).
0, 11, 101, 0, 10111, 101111, 1011001, 10010101, 101001001, 1000001011, 10000001101, 100000010101, 1000100000101, 10000000001011, 100000000100101, 1000000000100011, 10000000000001101, 100000000001010001, 1000000000000010011
Offset: 1
Links
- Robert Israel, Table of n, a(n) for n = 1..800
Programs
-
Maple
f:= proc(n) local s, c, i,Cands; for s from 2 to n do if s mod 3 = 0 then next fi; Cands:= sort(map(t -> 1 + 10^(n-1) + add(10^t[i],i=1..s-2), combinat:-choose([$1..n-2],s-2))); for c in Cands do if isprime(c) then return c fi od od; 0 end proc: map(f, [$1..20]); # Robert Israel, Aug 03 2020
Extensions
Extended by Ray Chandler, Dec 03 2009