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.

A004186 Arrange digits of n in decreasing order.

This page as a plain text file.
%I A004186 #49 Aug 07 2024 10:36:28
%S A004186 0,1,2,3,4,5,6,7,8,9,10,11,21,31,41,51,61,71,81,91,20,21,22,32,42,52,
%T A004186 62,72,82,92,30,31,32,33,43,53,63,73,83,93,40,41,42,43,44,54,64,74,84,
%U A004186 94,50,51,52,53,54,55,65,75,85,95,60,61,62,63,64,65,66,76,86,96,70,71,72
%N A004186 Arrange digits of n in decreasing order.
%C A004186 a(A009996(n)) = A009996(n). - _Reinhard Zumkeller_, Oct 31 2007
%C A004186 If we define "sortable primes" as prime numbers that remain prime when their digits are sorted in decreasing order, then all absolute primes (A003459) are sortable primes but not all sortable primes are absolute primes. For example, 113 is both sortable and absolute, and 313 is sortable but not absolute since its digits can be permuted to 133 = 7 * 19. - _Alonso del Arte_, Oct 05 2013
%H A004186 R. Zumkeller, <a href="/A004186/b004186.txt">Table of n, a(n) for n = 0..10000</a>
%F A004186 n <= a(n) < 10n. - _Charles R Greathouse IV_, Aug 07 2024
%e A004186 a(19) = 91 because the digits of 19 being 1 and 9, arranged in decreasing order they are 9 and 1.
%e A004186 a(20) = 20 because the digits are already in decreasing order.
%p A004186 A004186 := proc(n)
%p A004186     local dgs;
%p A004186     convert(n,base,10) ;
%p A004186     dgs := sort(%) ;
%p A004186     add( op(i,dgs)*10^(i-1),i=1..nops(dgs)) ;
%p A004186 end proc:
%p A004186 seq(A004186(n),n=0..20) ; # _R. J. Mathar_, Jul 26 2015
%t A004186 sortDigitsDown[n_] := FromDigits@ Reverse@ Sort@ IntegerDigits@ n; Array[sortDigitsDown, 73, 0] (* _Robert G. Wilson v_, Aug 19 2011 *)
%o A004186 (PARI)
%o A004186 reconstruct(m) = {local(r); r=0; for(i=1,matsize(m)[2],r=r*10+m[i]); r}
%o A004186 A004186(n) = reconstruct(vecsort(digits(n),,4))
%o A004186 \\ _Michael B. Porter_, Nov 11 2009
%o A004186 (PARI) a(n) = fromdigits(vecsort(digits(n), , 4)); \\ _Joerg Arndt_, Feb 24 2019
%o A004186 (Haskell)
%o A004186 import Data.List (sort)
%o A004186 a004186 = read . reverse . sort . show :: Integer -> Integer
%o A004186 -- _Reinhard Zumkeller_, Aug 19 2011
%o A004186 (Python)
%o A004186 def a(n): return int("".join(sorted(str(n), reverse=True)))
%o A004186 print([a(n) for n in range(73)]) # _Michael S. Branicky_, Feb 21 2021
%Y A004186 Cf. A004185, A004086, A009996, A064222, A194233, A032553, A032554, A028907, A028908.
%K A004186 nonn,base,look,easy
%O A004186 0,3
%A A004186 _N. J. A. Sloane_
%E A004186 More terms from _Reinhard Zumkeller_, Oct 31 2007