cp's OEIS Frontend

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.

Showing 1-10 of 17 results. Next

A046811 Numbers (with nonzero digits only) where A046810 increases.

Original entry on oeis.org

1, 2, 13, 113, 149, 1123, 1237, 11234, 11239, 12347, 12359, 12367, 12379, 13459, 13789, 111389, 112279, 112337, 112346, 112348, 112349, 112379, 112679, 113789, 123457, 123467, 123469, 123479, 1112347, 1112357, 1112359, 1113479, 1122349
Offset: 1

Views

Author

Keywords

Examples

			A046810(*) reaches 3 for the first time at 113.
		

Crossrefs

Programs

  • Maple
    S[1]:= [seq([i],i=1..9)]:
    for d from 2 to 7 do S[d]:= map(t -> seq([i,op(t)],i=t[1]..9),S[d-1]) od:
    f:= proc(L) local t,i;
      add(`if`(isprime(add(t[i]*10^(i-1),i=1..nops(t))),1,0),t=combinat:-permute(L))
    end proc:
    R:= NULL: m:= -1:
    for d from 1 to 7 do
    for L in S[d] do
        v:= f(L);
        if v > m then m:= v;  x:= add(L[i]*10^(i-1),i=1..nops(L)); R:= R,x; fi
    od od:
    R; # Robert Israel, Mar 31 2025

Extensions

Offset corrected by Robert Israel, Mar 31 2025

A046813 Smallest number m with nonzero digits such that A046810(m)=n.

Original entry on oeis.org

1, 2, 13, 113, 149, 1127, 1136, 1247, 1123, 1349, 1579, 1237, 11267, 11338, 11248, 11237, 11234, 11389, 11579, 13358, 11347, 11239, 12457, 12679, 12349, 12347, 13678, 12359, 14579, 13489, 111349, 12367, 12389, 23579, 13579, 112468, 12379
Offset: 0

Views

Author

Keywords

Programs

  • Maple
    N:= 100: # for a(0) .. a(N)
    f:= proc(L) local t, i;
      if convert(L,`+`) mod 3 = 0 then return 0 fi;
      add(`if`(isprime(add(t[i]*10^(i-1), i=1..nops(t))), 1, 0), t=combinat:-permute(L))
    end proc:
    V:= Array(0..N): count:= 0:
    for d from 1 while count < N+1 do
      if d = 1 then S:= [seq([i],i=1..9)]
    else S:= map(proc(t) local i; seq([i, op(t)], i=t[1]..9) end proc, S)
      fi;
      for L in S while count < N+1 do
        v:= f(L);
        if v <= N and V[v] = 0 then V[v] := add(L[i]*10^(i-1),i=1..nops(L)); count:= count+1 fi;
    od od:
    convert(V,list);

A039999 Number of permutations of digits of n which yield distinct primes.

Original entry on oeis.org

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, 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, 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
Offset: 1

Views

Author

Keywords

Comments

Consider all k! permutations of digits of a k-digit number n, discard initial zeros, count distinct primes.

Examples

			a(20) = 1, since from {02, 20} we get {2,20} and only 2 is prime.
From 107 we get 4 primes: (0)17, (0)71, 107 and 701; so a(107) = 4.
		

Crossrefs

Cf. A046810.
Cf. A039993 (number of primes embedded in n), A076730 (maximum for n digits), A072857 (record indices: primeval numbers), A134596 (largest with n digits).
Cf. A075053 (as A039993 but counted with multiplicity), A134597 (maximum for n digits).

Programs

  • Haskell
    import Data.List (permutations, nub)
    a039999 n = length $ filter ((== 1) . a010051)
                       (map read (nub $ permutations $ show n) :: [Integer])
    -- Reinhard Zumkeller, Feb 07 2011
    
  • 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 | [:i in [1..#x] ] > where x is [1..#y] where y is Intseq(n,10): n in [1..120] ]; // Klaus Brockhaus, Jun 15 2009
    
  • Mathematica
    Table[Count[FromDigits/@Permutations[IntegerDigits[n]],?PrimeQ], {n,110}] (* _Harvey P. Dale, Jun 26 2011 *)
  • PARI
    for(x=1, 400, print1(permprime(x), ",")) /* for definition of function permprime cf. link */ \\ Cino Hilliard, Jun 07 2009
    
  • 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
    
  • Python
    from sympy import isprime
    from itertools import permutations
    def a(n): return len(set(t for p in permutations(str(n)) if isprime(t:=int("".join(p)))))
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Feb 17 2024

Extensions

Contribution of Cino Hilliard edited by Klaus Brockhaus, Jun 15 2009
Edited by M. F. Hasler, Oct 14 2019

A075053 Number of primes (counted with repetition) that can be formed by rearranging some or all of the digits of n.

Original entry on oeis.org

0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 3, 1, 1, 1, 3, 0, 1, 1, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 3, 3, 2, 2, 3, 1, 4, 2, 1, 0, 1, 1, 2, 0, 1, 0, 2, 0, 0, 1, 1, 2, 3, 1, 2, 1, 2, 1, 2, 0, 1, 1, 1, 0, 1, 0, 2, 0, 0, 1, 3, 2, 4, 2, 2, 2, 2, 1, 3, 0, 0, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 2, 1, 0, 2, 0, 3, 1, 0, 0, 2, 1, 4, 2
Offset: 0

Views

Author

N. J. A. Sloane, Oct 12 2002

Keywords

Comments

"Counted with repetition" means that if the same prime can be obtained using different digits, then it is counted several times (e.g., 13 obtained from 113 using the 1st and 3rd digit or the 2nd and 3rd digit), but not so if it is obtained as different permutations of the same digits (e.g., a(11) = 1 because the identical permutation and the transposition (2,1) of the digits [1,1] both yield 11, but this does not count twice since the same digits are used). - M. F. Hasler, Mar 12 2014
See A039993 for the variant which counts only distinct primes, e.g., A039993(22) = 1, A039993(113) = 7. See A039999 for the variant which requires all digits to be used. - M. F. Hasler, Oct 14 2019

Examples

			From 13 we can obtain 3, 13 and 31 so a(13) = 3. In the same way, a(17) = 3.
From 22 we obtain 2 in two ways, so a(22) = 2.
a(101) = 2 because from the digits of 101 one can form the primes 11 (using digits 1 & 3) and 101 (using all digits). The prime 11 = 011 formed using all 3 digits does not count separately because it has a leading zero.
a(111) = 3 because one can form the prime 11 using digits 1 & 2, 1 & 3 or 2 & 3.
		

Crossrefs

Different from A039993 (counts only distinct primes). Cf. A072857, A076449.
Cf. A039999 (use all digits, count only distinct primes, allow leading zeros), A046810 (similar but don't allow leading zeros).
Cf. A134597 (maximum over all n-digit numbers), A076730 (maximum of A039993 for all n-digit numbers).
Cf. A239196 and A239197 for record indices and values.

Programs

  • Mathematica
    f[n_] := Length@ Select[ Union[ FromDigits@# & /@ Flatten[ Subsets@# & /@ Permutations@ IntegerDigits@ n, 1]], PrimeQ@# &]; Array[f, 105, 0] (* Robert G. Wilson v, Mar 12 2014 *)
  • PARI
    A075053(n,D=vecsort(digits(n)),S=0)=for(b=1,2^#D-1,forperm(vecextract(D,b),p,p[1]&&isprime(fromdigits(Vec(p)))&&S++));S \\ Second optional arg allows to give the digits if they are already known. - M. F. Hasler, Oct 14 2019, replacing earlier code from 2014.
    
  • Python
    from itertools import combinations
    from sympy.utilities.iterables import multiset_permutations
    from sympy import isprime
    def A075053(n): return sum(1 for l in range(1,len(str(n))+1) for a in combinations(str(n),r=l) for b in multiset_permutations(a) if b[0] !='0' and isprime(int(''.join(b)))) # Chai Wah Wu, Sep 13 2022

Formula

a(n) >= A039993(n) with equality iff n has no duplicate digit. - M. F. Hasler, Oct 14 2019
a(n) = Sum_{k in S(n)} A039999(k), if n has not more than one digit 0, where S(n) are the numbers whose nonzero digits are a subsequence of those of n, and which contain the digit 0 if n does, taken with multiplicity (for numbers using some but not all digits that are repeated in n). - M. F. Hasler, Oct 15 2019

Extensions

Corrected and extended by John W. Layman, Oct 15 2002
Examples & crossrefs edited by M. F. Hasler, Oct 14 2019

A055098 Number of distinct anagrams of digits of n without leading zeros.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 4
Offset: 1

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Examples

			a(101)=2 since the digits of 101 can be ordered 101 or 110 (but not 011).
		

Crossrefs

Programs

  • Haskell
    import Data.List (permutations, nub)
    a055098 n = length $ nub $ filter ((> '0') . head) $ permutations $ show n
    -- Reinhard Zumkeller, Aug 14 2011
    
  • Mathematica
    a[n_] := Length[ DeleteCases[ Permutations[ IntegerDigits[n]], {0 .., }]]; Table[a[n], {n, 1, 102}] (* Jean-François Alcover, Nov 30 2011 *)
  • PARI
    a(n)={my(v=digits(n), f=vector(10), n=#v); for(i=1, #v, f[1+v[i]]++); (1 - f[1]/n) * n! / prod(i=1, #f, f[i]!)} \\ Andrew Howroyd, Jan 27 2020
    
  • Python
    from math import factorial, prod
    def a(n):
        s = str(n); d, c = len(s), [s.count(str(i)) for i in range(10)]
        return (d-c[0])*factorial(d-1)//prod(map(factorial, c))
    print([a(n) for n in range(1, 50)]) # Michael S. Branicky, Aug 24 2022

Formula

a(n) = O(n/(log n)^(9/2)). - Charles R Greathouse IV, Aug 24 2022

A131371 Number of anagrams of n that are semiprimes.

Original entry on oeis.org

0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 2, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 2, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 2, 0, 1, 0, 1, 0, 0, 1, 1, 0, 2, 0, 2, 1, 1, 0, 1, 1, 1, 2, 1, 0, 0, 2, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 2, 1, 1, 0, 0, 0, 1, 0, 2, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1
Offset: 1

Views

Author

Jonathan Vos Post, Sep 30 2007

Keywords

Comments

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

Examples

			a(123) = 3 because 123 = 3 * 41 is semiprime, 213 = 3 * 71 is semiprime, 321 = 3 * 107 is semiprime, while the other anagrams 132, 231 and 312 have respectively 3, 3 and 5 prime factors with multiplicity.
a(129) = 4 because 129 = 3 * 43 is semiprime, 219 = 3 * 73 is semiprime, 291 = 3 * 97 is semiprime, 921 = 3 * 307 is semiprime, while 192 and 912 have 7 and 6 prime factors with multiplicity.
a(134) = 5 because 134 = 2 * 67 and 143 = 11 * 13 and 314 = 2 * 157 and 341 = 11 * 31 and 413 = 7 * 59 are semiprimes, while 431 is prime.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local L,m,t,i;
      L:= convert(n,base,10); m:= nops(L);
      nops(select(t -> t[-1] <> 0 and numtheory:-bigomega(add(t[i]*10^(i-1), i=1..m))=2, combinat:-permute(L)));
    end proc:
    map(f, [$1..200]); # Robert Israel, Jun 11 2023
  • Python
    from sympy import factorint
    from sympy.utilities.iterables import multiset_permutations as mp
    def c(n):
        return sum(factorint(n).values()) == 2
    def a(n):
        return sum(1 for p in mp(str(n)) if p[0]!="0" and c(t:=int("".join(p))))
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Jun 11 2023

A235993 Numbers having at least one anagram which is a square.

Original entry on oeis.org

1, 4, 9, 16, 18, 25, 36, 46, 49, 52, 61, 63, 64, 81, 94, 100, 112, 121, 136, 144, 148, 163, 169, 184, 196, 211, 225, 234, 243, 252, 256, 259, 265, 279, 289, 295, 297, 298, 316, 324, 342, 361, 400, 414, 418, 423, 432, 441, 448, 478, 481, 484, 487, 522, 526
Offset: 1

Views

Author

Colin Barker, Jan 19 2014

Keywords

Comments

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

Examples

			121 is in the sequence because 121 = 11^2.
619 is in the sequence because 169, 196 and 961 are squares.
		

Crossrefs

Cf. A000290, A007936 (leading zeros allowed), A046810, A055098, A235994.

A046890 a(n) is the least integer that has exactly n anagrams that are primes.

Original entry on oeis.org

1, 2, 13, 113, 149, 1013, 1039, 1247, 1123, 1349, 1579, 1237, 10127, 10238, 10139, 10235, 10234, 10457, 11579, 10789, 10237, 11239, 12457, 10279, 12349, 12347, 13678, 12359, 14579, 13489, 10379, 12367, 12389, 23579, 13579, 100349, 12379
Offset: 0

Views

Author

Keywords

Comments

An anagram is a permutation of digits not beginning with 0.

Crossrefs

Cf. A046810.

Programs

  • Mathematica
    ap[n_] := Count[FromDigits /@ Select[Permutations[IntegerDigits[n]], First[#] != 0 &], ?PrimeQ]; t = {1}; Do[i = 1; While[ap[i] != n, i++]; AppendTo[t, i], {n, 30}]; t (* _Jayanta Basu, Jun 29 2013 *)
  • Python
    from sympy import isprime
    from sympy.utilities.iterables import multiset_permutations as mp
    from itertools import count, islice, combinations_with_replacement as mc
    def nd(d): yield from ("".join((f,)+m) for f in "123456789" for m in mc("0123456789", d-1))
    def c(s): return sum(1 for p in mp(s) if p[0]!="0" and isprime(int("".join(p))))
    def agen(): # generator of sequence terms
        n, adict = 0, dict()
        for digs in count(1):
            for s in nd(digs):
                v = c(s)
                if v not in adict: adict[v] = int(s)
                while n in adict: yield adict[n]; n += 1
    print(list(islice(agen(), 40))) # Michael S. Branicky, Feb 08 2023

A061264 Number of cyclic permutations of the digits of n which give primes.

Original entry on oeis.org

0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 2, 0, 2, 1, 0, 1, 2, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 2, 1, 0, 1, 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, 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, 2, 1, 0
Offset: 1

Views

Author

Amarnath Murthy, Apr 24 2001

Keywords

Examples

			a(157) = 2 as among the three cyclic permutations 157, 571, 715, two are primes.
		

Crossrefs

Cf. A039999.
Cf. A046810. - R. J. Mathar, Oct 02 2008

Programs

  • Maple
    A055642 := proc(n) max(1,ilog10(n)+1) ; end: A061264 := proc(n) local ncyc,s,dgs,a,L,i ; a := 0 ; dgs := convert(n,base,10) ; ncyc := n ; for s from 1 to A055642(n) do if isprime(ncyc) then a := a+1 ; fi; L := ListTools[Rotate](dgs,s) ; ncyc := add(op(i,L)*10^(i-1),i=1..nops(L)) ; od: RETURN(a) ; end: for n from 1 to 120 do printf("%d,",A061264(n)) ; od: # R. J. Mathar, Oct 02 2008

Extensions

More terms from R. J. Mathar, Oct 02 2008
Offset corrected, Joerg Arndt, Aug 05 2015

A166921 Least prime with exactly n prime anagrams not equal to itself.

Original entry on oeis.org

2, 13, 113, 149, 1013, 1039, 1427, 1123, 1439, 1579, 1237, 10271, 10453, 10139, 10253, 10243, 10457, 11579, 10789, 10273, 11239, 12457, 10729, 13249, 12347, 13687, 12539, 14759, 13799, 10739, 12637, 12893, 23957, 13597, 100493, 12379, 14593, 101383, 13789
Offset: 0

Views

Author

Pierre CAMI, Oct 23 2009

Keywords

Comments

13 has only one prime anagram (31), and no smaller prime has a prime anagram other than itself, so a(1) = 13.
113 has 2 prime anagrams (131 and 311), and no smaller prime has two prime anagrams other than itself, so a(2) = 113.
149 has 3 prime anagrams (419, 491, and 941), and no smaller prime has three prime anagrams other than itself, so a(3) = 149.

Examples

			a(7) = prime 1123 with 7 prime anagrams 1213, 1231, 1321, 2113, 2131, 2311, 3121.
		

Crossrefs

Programs

  • Python
    # see link for faster version
    from sympy import isprime
    from itertools import permutations
    def anagrams(n):
      s = str(n)
      return set(int("".join(p)) for p in permutations(s) if p[0] != '0')
    def num_prime_anagrams(n): return sum(isprime(i) for i in anagrams(n))
    def a(n):
      if n == 0: return 2
      k = 3
      while not isprime(k) or num_prime_anagrams(k) != n+1: k += 2
      return k
    print([a(n) for n in range(39)]) # Michael S. Branicky, Feb 13 2021

Extensions

Definition edited and a(0) added by Chai Wah Wu, Dec 26 2016
Showing 1-10 of 17 results. Next