(Translated by https://www.hiragana.jp/)
A004185 - OEIS
login
A004185
Arrange digits of n in increasing order, then (for n > 0) omit the zeros.
43
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,3
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
LINKS
EXAMPLE
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.
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 *)
PROG
(Haskell)
import Data.List (sort)
a004185 n = read $ sort $ show n :: Integer
-- Reinhard Zumkeller, Aug 10 2011
(Magma) A004185:=func<n | Seqint(Reverse(Sort(Intseq(n))))>; [n eq 0 select 0 else A004185(n): n in [0..57]]; // Bruno Berselli, Apr 03 2012
(Python)
def A004185(n):
return int(''.join(sorted(str(n))).replace('0', '')) if n > 0 else 0 # Chai Wah Wu, Nov 10 2015
(PARI) a(n)=fromdigits(vecsort(digits(n))) \\ Charles R Greathouse IV, Feb 06 2017
CROSSREFS
Cf. A211654 (sortable primes) and subsequence A086042 (nontrivial solutions).
Sequence in context: A331472 A364362 A059717 * A068636 A328131 A004719
KEYWORD
nonn,base,nice,easy,look
STATUS
approved