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!)
A046810 Number of anagrams of n that are primes. 18

%I #18 Feb 17 2024 04:24:32

%S 0,1,1,0,1,0,1,0,0,0,1,0,2,1,0,1,2,0,1,0,0,0,1,0,0,0,0,0,1,0,2,1,0,1,

%T 1,0,2,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,

%U 0,0,2,0,2,1,0,1,0,0,2,0,0,0,1,0,0,0,0,0,1,0,1,1,0,0,1,0,2,1,0,0,1,0,1,1,0,1,2,0

%N Number of anagrams of n that are primes.

%C An anagram of a k-digit number is one of the k! permutations of the digits that does not begin with 0.

%H Reinhard Zumkeller, <a href="/A046810/b046810.txt">Table of n, a(n) for n = 1..10000</a>

%e 107 has 2 prime anagrams: 107 and 701 (but not 017 or 071); so a(107) = 2.

%t Table[Count[FromDigits/@Select[Permutations[IntegerDigits[n]], First[#] != 0&],_?(PrimeQ[#]&)],{n,110}] (* _Harvey P. Dale_, Aug 24 2011 *)

%o (Haskell)

%o import Data.List (permutations, nub)

%o a046810 n = length $ filter ((== 1) . a010051)

%o $ map read (nub $ filter ((> '0') . head)

%o $ permutations $ show n)

%o -- _Reinhard Zumkeller_, Aug 14 2011

%o (Python)

%o from sympy import isprime

%o from itertools import permutations

%o def a(n): return len(set(t for p in permutations(str(n)) if p[0]!="0" and isprime(t:=int("".join(p)))))

%o print([a(n) for n in range(1, 106)]) # _Michael S. Branicky_, Feb 17 2024

%Y Cf. A039999, A055098.

%K nonn,easy,base,nice

%O 1,13

%A _David W. Wilson_

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 August 1 14:59 EDT 2024. Contains 374818 sequences. (Running on oeis4.)