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.
%I A039999 #39 Feb 17 2024 04:02:18 %S A039999 0,1,1,0,1,0,1,0,0,0,1,0,2,1,0,1,2,0,1,1,0,0,1,0,0,0,0,0,1,1,2,1,0,1, %T A039999 1,0,2,1,0,0,1,0,1,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0, %U A039999 0,1,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,2,0,3,2,0 %N A039999 Number of permutations of digits of n which yield distinct primes. %C A039999 Consider all k! permutations of digits of a k-digit number n, discard initial zeros, count distinct primes. %H A039999 T. D. Noe, <a href="/A039999/b039999.txt">Table of n, a(n) for n = 1..10000</a> %H A039999 C. Hilliard, <a href="/A039999/a039999.txt">PARI program.</a> %e A039999 a(20) = 1, since from {02, 20} we get {2,20} and only 2 is prime. %e A039999 From 107 we get 4 primes: (0)17, (0)71, 107 and 701; so a(107) = 4. %t A039999 Table[Count[FromDigits/@Permutations[IntegerDigits[n]],_?PrimeQ], {n,110}] (* _Harvey P. Dale_, Jun 26 2011 *) %o A039999 (PARI) for(x=1, 400, print1(permprime(x), ",")) /* for definition of function permprime cf. link */ \\ _Cino Hilliard_, Jun 07 2009 %o A039999 (PARI) A039999(n,D=vecsort(digits(n)),S)={forperm(D,p, isprime(fromdigits(Vec(p))) && S++);S} \\ Giving the 2nd arg avoids computing it and increases efficiency when the digits are already known. Must be sorted because forperm() only considers "larger" permutations. - _M. F. Hasler_, Oct 14 2019 %o A039999 (Magma) [ #[ s: s in Seqset([ Seqint([m(p[i]):i in [1..#x] ], 10): p in Permutations(Seqset(x)) ]) | IsPrime(s) ] where m is map< x->y | [<x[i],y[i]>:i in [1..#x] ] > where x is [1..#y] where y is Intseq(n,10): n in [1..120] ]; // _Klaus Brockhaus_, Jun 15 2009 %o A039999 (Haskell) %o A039999 import Data.List (permutations, nub) %o A039999 a039999 n = length $ filter ((== 1) . a010051) %o A039999 (map read (nub $ permutations $ show n) :: [Integer]) %o A039999 -- _Reinhard Zumkeller_, Feb 07 2011 %o A039999 (Python) %o A039999 from sympy import isprime %o A039999 from itertools import permutations %o A039999 def a(n): return len(set(t for p in permutations(str(n)) if isprime(t:=int("".join(p))))) %o A039999 print([a(n) for n in range(1, 106)]) # _Michael S. Branicky_, Feb 17 2024 %Y A039999 Cf. A046810. %Y A039999 Cf. A039993 (number of primes embedded in n), A076730 (maximum for n digits), A072857 (record indices: primeval numbers), A134596 (largest with n digits). %Y A039999 Cf. A075053 (as A039993 but counted with multiplicity), A134597 (maximum for n digits). %K A039999 nonn,base,nice %O A039999 1,13 %A A039999 _David W. Wilson_ %E A039999 Contribution of _Cino Hilliard_ edited by _Klaus Brockhaus_, Jun 15 2009 %E A039999 Edited by _M. F. Hasler_, Oct 14 2019