A272107 Absolute primes in base 8: every permutation of digits in base 8 is a prime (only the smallest representatives of the permutation classes are shown).
2, 3, 5, 7, 13, 29, 31, 47, 73, 1759
Offset: 1
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.
a(6) = 15 because 15 and 51 are lucky numbers. a(14) = 115 because (115, 151, 511) are all lucky numbers.
The other numbers resulting from all possible permutations of the digits of 113 are 131 and 311. 113, 131 and 311 are all primes, so all three numbers are terms of this sequence.
eva(n) = subst(Pol(n), x, 10) find_index_a(vec) = my(r=#vec-1); while(1, if(vec[r] < vec[r+1], return(r)); r--; if(r==0, return(-1))) find_index_b(r, vec) = my(s=#vec); while(1, if(vec[r] < vec[s], return(s)); s--; if(s==r, return(-1))) switch_elements(vec, firstpos, secondpos) = my(g); g=vec[secondpos]; vec[secondpos]=vec[firstpos]; vec[firstpos] = g; vec reverse_order(vec, r) = my(v=[], w=[]); for(x=1, r, v=concat(v, vec[x])); for(y=r+1, #vec, w=concat(w, vec[y])); w=Vecrev(w); concat(v, w) next_permutation(vec) = my(r=find_index_a(vec)); if(r==-1, return(0), my(s=find_index_b(r, vec)); vec=switch_elements(vec, r, s); vec=reverse_order(vec, r)); vec is(n) = if(n < 10, return(1)); my(d=vecsort(digits(n))); if(vecmin(d)==0 || vecmax(d)==1, return(0)); while(1, if(!ispseudoprime(eva(d)), return(0)); d=next_permutation(d); if(d==0, return(1))) forprime(p=1, , if(is(p), print1(p, ", ")))
156 is a term because omega(156) = omega(165) = omega (516) = omega(561) = omega(615) = omega(651) = 3, where omega(n) is the number of distinct prime divisors of n.
Select[Range[10000],CountDistinct[PrimeNu[FromDigits /@ Permutations[IntegerDigits[#]]]]==1&&CountDistinct[IntegerDigits[#]]>1&]
from sympy import factorint from itertools import permutations def ok(n): s, pf = str(n), len(factorint(n)) if len(set(s)) == 1: return False return all(pf==len(factorint(int("".join(p)))) for p in permutations(s)) print([k for k in range(500) if ok(k)]) # Michael S. Branicky, Jun 05 2022
113 is a term because 113 and permutations 131 and 311 are prime as is 1+1+3=5. 11111111111111111111111 is a term because it is prime, all permutations of its digits are prime, the sum of its digits, 23, is prime and 2+3=5 is also prime.
14=2*7 (composite) is a term as a permutation of its digits gives 41 (prime). Hence 41 is also a term. 19 (prime) is a term as 91=7*13 (composite). Thus 91 is also a term. 130=2*5*13 (composite) is a term (even though the permutation 310=2*5*31 is also composite) because another permutation (0)13 (prime) exists (dropping the leading 0). 13, however, is not a term as 31 is also prime (13 and 31 are members of A003459).
127 is not in the sequence since 271 is prime but neither 217 nor 721 are; to be in the sequence all of these numbers would have to be prime, and they would form an orbit of size 4 (by Name, permutations of these numbers ending in 2 are not considered). 241 and 421 are in the sequence and form an orbit of size 2 since these primes can be obtained by permutations that forbid the units digit to be an even number. 569 and 659 are in the sequence since these primes can be obtained by permutations that forbid the units digit to be either 5 or an even number.
filter:= proc(n) local L,m,i,t; if not isprime(n) then return false fi; L:= convert(n,base,10); m:=nops(L); for i in select(t -> member(L[t],[1,3,7,9]), [$1..m]) do for t in combinat:-permute(subsop(i=NULL, L)) do if not isprime(L[i]+add(10^j*t[j],j=1..m-1)) then return false fi od od; true end proc: select(filter, [2,seq(i,i=3..2000,2)]); # Robert Israel, Aug 31 2018
Select[Prime@Range[120], AllTrue[FromDigits /@ Permutations[IntegerDigits@ #], PrimeQ[#] || MemberQ[{0, 2, 4, 5, 6, 8}, Mod[#, 10]] &] &] (* Giovanni Resta, Jul 14 2018 *)
find_index_a(vec) = my(r=#vec-1); while(1, if(vec[r] < vec[r+1], return(r)); r--; if(r==0, return(-1))) find_index_b(r, vec) = my(s=#vec); while(1, if(vec[r] < vec[s], return(s)); s--; if(s==r, return(-1))) switch_elements(vec, firstpos, secondpos) = my(g); g=vec[secondpos]; vec[secondpos]=vec[firstpos]; vec[firstpos] = g; vec reverse_order(vec, r) = my(v=[], w=[]); for(x=1, r, v=concat(v, vec[x])); for(y=r+1, #vec, w=concat(w, vec[y])); w=Vecrev(w); concat(v, w) next_permutation(vec) = my(r=find_index_a(vec)); if(r==-1, return(0), my(s=find_index_b(r, vec)); vec=switch_elements(vec, r, s); vec=reverse_order(vec, r)); vec decimal(v, base) = my(w=[]); for(k=0, #v-1, w=concat(w, v[#v-k]*base^k)); sum(i=1, #w, w[i]) is_absolute_prime(n, base) = my(db=vecsort(digits(n, base))); if(vecmin(db)==0 || vecmax(db)==1, return(0)); while(1, my(dec=decimal(db, base)); if(!ispseudoprime(dec), return(0)); db=next_permutation(db); if(db==0, return(1))) a(n) = my(absp=0, lim=10^7, i=0); forprime(p=n+1, , if(is_absolute_prime(p, n), absp=p); i++; if(i==lim, return(absp)))
480 = 4*120, 408 = 4*102, 840 = 4*210, 804 = 4*201, 048 = 4*12, 084 = 4*21.
f:= proc(n) local L,i; L:= convert(n,base,3); 4*add(L[i]*10^(i-1),i=1..nops(L)) end proc: map(f, [$0..100]); # Robert Israel, Apr 30 2021
FromDigits /@ Tuples[{0, 4, 8}, 4] (* Amiram Eldar, Apr 30 2021 *)
a(n) = fromdigits(digits(n, 3))*4 \\ Rémy Sigrist, May 05 2021
10 = 4*5/2, 01 = 1*2/2.
triQ[n_] := IntegerQ @ Sqrt[8*n + 1]; Select[Range[0, 1000], AllTrue[Permutations[ IntegerDigits[#] ], triQ[FromDigits[#1]] &] &] (* Amiram Eldar, Apr 30 2021 *) pdtQ[n_]:=AllTrue[FromDigits/@Permutations[IntegerDigits[n]],OddQ[ Sqrt[ 8#+1]]&]; Select[Accumulate[Range[0,5000]],pdtQ] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jul 04 2021 *)
Comments