login
Primes that contain digits 5 and 7 only.
9

%I #17 Sep 08 2022 08:44:45

%S 5,7,557,577,757,5557,7577,7757,57557,75557,75577,77557,555557,575557,

%T 575777,577757,757577,775757,775777,5555777,5557757,5575777,5577577,

%U 5755577,5775557,5777557,7575577,7577777,55555777,55575757,55755757,55757777,57557557

%N Primes that contain digits 5 and 7 only.

%H Vincenzo Librandi, <a href="/A020467/b020467.txt">Table of n, a(n) for n = 1..1000</a>

%t Flatten[Table[Select[FromDigits/@Tuples[{5,7},n],PrimeQ],{n,8}]]

%o (Magma) [p: p in PrimesUpTo(55755757 ) | Set(Intseq(p)) subset [5, 7]];// _Vincenzo Librandi_, Jul 27 2012

%o (Python)

%o from sympy import isprime

%o from sympy.utilities.iterables import multiset_permutations

%o def aupton(terms):

%o n, digits, alst = 0, 1, []

%o while len(alst) < terms:

%o mpstr = "".join(d*digits for d in "57")

%o for mp in multiset_permutations(mpstr, digits):

%o t = int("".join(mp))

%o if isprime(t): alst.append(t)

%o if len(alst) == terms: break

%o else: digits += 1

%o return alst

%o print(aupton(33)) # _Michael S. Branicky_, May 07 2021

%Y Subsequence of A260827-A260831 and A284380.

%K nonn,base

%O 1,1

%A _David W. Wilson_