login
Smallest n-digit prime with digits from {1,4,7} only, or 0 if no such prime exists.
1

%I #7 Mar 09 2020 09:13:38

%S 7,11,0,1117,11117,0,1111447,11111117,0,1111111411,11111111741,0,

%T 1111111111177,11111111111411,0,1111111111111447,11111111111111171,0,

%U 1111111111111111111,11111111111111111447,0,1111111111111111111711

%N Smallest n-digit prime with digits from {1,4,7} only, or 0 if no such prime exists.

%C Any 3k-digit number containing only digits from {1,4,7} has a digit-sum divisible by 3. Therefore the number is divisible by 3 and a(3k) = 0 for all positive integers k.

%H Jinyuan Wang, <a href="/A091920/b091920.txt">Table of n, a(n) for n = 1..1000</a>

%F a(k) <= minimum(A036931(k), A036934(k), A036944(k)), a(3k) = 0 and a(A004023(k)) = (10^A004023(k) - 1)/9 = A004022(k) for all positive integers k. (The inequality above holds iff a(k) contains at least one of each digit 1, 4 and 7.)

%t Flatten[Table[Select[FromDigits/@Tuples[{1, 4, 7}, n], PrimeQ, 1], {n, 25}]/.{}->{0}] (* _Jinyuan Wang_, Mar 09 2020 *)

%Y Other smallest n-digit primes: A036931 (digits from {1, 4} only), A036934 (digits from {1, 7} only), A036944 (digits from {4, 7} only), A004022 (repunit primes), A004023.

%K nonn,base

%O 1,1

%A _Rick L. Shepherd_, Feb 12 2004