login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A272022 Look at the set of numbers obtained by permuting the digits of n in all possible ways, then remove n itself from the set. If the remaining numbers are all primes, then n is in the sequence. 0

%I #30 Dec 29 2023 10:56:56

%S 13,14,16,17,20,30,31,32,34,35,37,38,50,70,71,73,74,76,79,91,92,95,97,

%T 98,110,113,118,119,131,133,199,311,337,373,733,772,775,778,779,919,

%U 991,1118,3337,7771,77779

%N Look at the set of numbers obtained by permuting the digits of n in all possible ways, then remove n itself from the set. If the remaining numbers are all primes, then n is in the sequence.

%C If it exists, a(46) > 5*10^11. - _Lars Blomberg_, Mar 31 2018

%e 119 is in the sequence because every permutation of its digits excluding 119 (i.e., 191 and 911) is a prime.

%e 11 is not in the sequence, because when 11 is removed from the set, no numbers are left.

%p lis := [];

%p for n from 1 to 10000 do

%p nn := convert(n, base, 10);

%p pp := combinat[permute](nn);

%p if nops(pp) = 1 then

%p next

%p end if;

%p lOk := true;

%p for p in pp do

%p if p = nn then

%p next: #exclude n

%p end if;

%p if `not`(isprime(convert(p, base, 10, 10^nops(p))[])) then

%p lOk := false; break

%p end if

%p end do;

%p if lOk then

%p lis := [op(lis), n]

%p end if

%p end do:

%p lis := lis;

%t rnapQ[n_]:=Module[{p=Rest[FromDigits/@Permutations[IntegerDigits[ n]]]},If[ Length[p]==0, False, AllTrue[p,PrimeQ]]]; Select[Range[80000],rnapQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Jan 24 2019 *)

%o (PARI) isok(n) = {v = []; d = digits(n); for (k=0, (#d)!-1, p = numtoperm(#d, k); dp = vector(#d, j, d[p[j]]); np = subst(Pol(dp), x, 10); v = Set(concat(v, np));); v = setminus(v, Set(n)); if (#v == 0, return (0)); for (k=1, #v, if (!isprime(v[k]), return (0));); return (1);} \\ _Michel Marcus_, Apr 18 2016

%o (Python)

%o from sympy import isprime

%o from itertools import count, islice, permutations

%o def agen(): yield from (k for k in count(1) if len(set(s:=str(k)))!=1 and all((t:=int("".join(m)))==k or isprime(t) for m in permutations(s)))

%o print(list(islice(agen(), 45))) # _Michael S. Branicky_, Dec 29 2023

%Y Cf. A095179, A111347.

%Y Cf. A003459. - _Altug Alkan_, Apr 18 2016

%K nonn,base,more

%O 1,1

%A _César Eliud Lozada_, Apr 18 2016

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 5 18:56 EDT 2024. Contains 372277 sequences. (Running on oeis4.)