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-4 of 4 results.

A004185 Arrange digits of n in increasing order, then (for n > 0) omit the zeros.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 12, 22, 23, 24, 25, 26, 27, 28, 29, 3, 13, 23, 33, 34, 35, 36, 37, 38, 39, 4, 14, 24, 34, 44, 45, 46, 47, 48, 49, 5, 15, 25, 35, 45, 55, 56, 57, 58, 59, 6, 16, 26, 36, 46, 56, 66, 67, 68, 69, 7, 17, 27, 37, 47
Offset: 0

Views

Author

Keywords

Comments

Record values: A009994. - Reinhard Zumkeller, Dec 05 2009
If we define "sortable primes" as prime numbers that remain prime when their digits are sorted in increasing order, then all absolute primes (A003459) are sortable primes but not all sortable primes are absolute primes. For example, 311 is both sortable and absolute, and 271 is sortable but not absolute, since its digits can be permuted to 217 = 7 * 31 or 712 = 2^3 * 89, etc. - Alonso del Arte, Oct 05 2013
The above mentioned "sortable primes" are listed in A211654, the nontrivial ones (with digits not in nondecreasing order) in A086042. - M. F. Hasler, Jul 30 2019

Examples

			a(19) = 19 because the digits are already in increasing order.
a(20) = 2 because the digits of 20 are 2 and 0, which in increasing order are 0 and 2, but since zero-padding is not allowed on the left, the zero digit is dropped and we are left with 2.
a(21) = 12 because the digits of 21 are 2 and 1, which in increasing order are 1 and 2.
		

Crossrefs

Cf. A211654 (sortable primes) and subsequence A086042 (nontrivial solutions).

Programs

  • Haskell
    import Data.List (sort)
    a004185 n = read $ sort $ show n :: Integer
    -- Reinhard Zumkeller, Aug 10 2011
    
  • Magma
    A004185:=func; [n eq 0 select 0 else A004185(n): n in [0..57]]; // Bruno Berselli, Apr 03 2012
    
  • Maple
    A004185 := proc(n)
        local dgs;
        convert(n,base,10) ;
        dgs := sort(%,`>`) ;
        add( op(i,dgs)*10^(i-1),i=1..nops(dgs)) ;
    end proc:
    seq(A004185(n),n=0..20) ; # R. J. Mathar, Jul 26 2015
  • Mathematica
    FromDigits[Sort[DeleteCases[IntegerDigits[#], 0]]]&/@Range[0, 60] (* Harvey P. Dale, Nov 29 2011 *)
  • PARI
    a(n)=fromdigits(vecsort(digits(n))) \\ Charles R Greathouse IV, Feb 06 2017
  • Python
    def A004185(n):
        return int(''.join(sorted(str(n))).replace('0','')) if n > 0 else 0 # Chai Wah Wu, Nov 10 2015
    

A086042 Nontrivial numbers which are prime and yield another prime when their digits are sorted in ascending order.

Original entry on oeis.org

31, 71, 73, 97, 101, 103, 107, 109, 131, 173, 193, 197, 271, 293, 307, 311, 317, 373, 397, 419, 439, 491, 509, 547, 571, 593, 607, 617, 647, 659, 673, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 809, 839, 907, 919, 937, 941, 947, 953, 971, 983, 991
Offset: 1

Views

Author

Chuck Seggelin, Jul 07 2003

Keywords

Comments

Primes with digits already in ascending order (like 13 and 2357) are trivial cases and are therefore excluded.
See A211654 for the sequence including the trivial cases. - M. F. Hasler, Jul 30 2019

Examples

			a(1)=31 because an ascending sort of 31's digits yields 13 which is also prime. a(53)=1009 because an ascending sort of 1009's digits yields 19 which is also prime.
		

Crossrefs

Programs

  • Magma
    [p:p in PrimesUpTo(1000)|  IsPrime(Seqint(Reverse(Sort(Intseq(p,10))))) and p ne Seqint(Reverse(Sort(Intseq(p,10)))) ]; // Marius A. Burtea, Jul 30 2019
  • Mathematica
    paoQ[n_]:=Module[{idn=IntegerDigits[n],sidn},sidn=Sort[idn];sidn!=idn && PrimeQ[FromDigits[sidn]]] (* Harvey P. Dale, Nov 14 2011 *)
  • PARI
    select( is_A086042(p,q=fromdigits(vecsort(digits(p))))={p>q&&isprime(q)&&isprime(p)}, [1..999]) \\ M. F. Hasler, Jul 30 2019
    

A182150 Semiprimes that are also semiprime when their digits are sorted into nondecreasing order.

Original entry on oeis.org

4, 6, 9, 14, 15, 22, 25, 26, 33, 34, 35, 38, 39, 46, 49, 51, 55, 57, 58, 62, 69, 77, 85, 93, 94, 111, 115, 118, 119, 122, 123, 129, 133, 134, 143, 145, 146, 155, 158, 159, 166, 169, 177, 178, 185, 187, 202, 205, 206, 213, 219, 221, 226, 235, 237, 247, 249, 253
Offset: 1

Views

Author

Jonathan Vos Post, Apr 18 2012

Keywords

Comments

This is to A211654 primes that are also prime when their digits are sorted into nondecreasing order as A001358 semiprimes are to A000040 primes. There is an ambiguity arising from OEIS conventions, exemplified by the semiprime 303, which sorts to 033 and truncates to the semiprime 33.

Examples

			51 is in the sequence because, though it is a semiprime whose digits are in descending order, once the digits are sorted to be nondecreasing, it is the semiprime 15, whose digits are (left to right) nondecreasing.
		

Crossrefs

Programs

  • Maple
    h:= proc(m) local k; for k from m+1 while isprime(k) or
                add(i[2], i=ifactors(k)[2])<>2 do od; k
        end:
    a:= proc(n) option remember; local k, l, s;
          k:= h(a(n-1));
          do l:= sort(convert(k, base, 10));
             s:= add(l[i]*10^(nops(l)-i), i=1..nops(l));
             if h(s-1)=s then return k else k:=h(k) fi
          od
        end: a(0):=0:
    seq(a(n), n=1..100);  # Alois P. Heinz, Apr 22 2012
  • Mathematica
    Select[Range[300],PrimeOmega[#]==2&&PrimeOmega[FromDigits[ Sort[ IntegerDigits[ #]]]]==2&] (* Harvey P. Dale, Nov 13 2014 *)

Extensions

More terms from Alois P. Heinz, Apr 22 2012

A211655 Down-sortable primes: Primes that are also primes after digits are sorted into decreasing order.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 31, 37, 41, 43, 53, 61, 71, 73, 79, 83, 97, 113, 131, 149, 157, 163, 167, 179, 181, 191, 197, 199, 211, 241, 251, 281, 311, 313, 331, 337, 347, 359, 373, 389, 419, 421, 431, 433, 443, 461, 463, 491, 521, 541, 563, 571, 593, 613, 617, 631, 641, 643, 653
Offset: 1

Views

Author

Francis J. McDonnell, Apr 17 2012

Keywords

Comments

All 1- and 2-digit reversible primes (A007500) are trivially in this sequence. No primes from A056709 are in this sequence. Clearly all absolute primes (A003459) are sortable primes but not all sortable primes are absolute primes. - Alonso del Arte, Oct 08 2013

Examples

			131 is prime and after sorting its digits into nonincreasing order we obtain 311, which is prime.
163 is in the sequence because its digits sorted in decreasing order give 631, which is prime. (Note that this is not a reversible prime, since 361 = 19^2.)
		

Crossrefs

Programs

  • Mathematica
    Select[Prime[Range[200]], PrimeQ[FromDigits[-Sort[-IntegerDigits[#]]]] &] (* T. D. Noe, Apr 17 2012 *)
Showing 1-4 of 4 results.