OFFSET
0,3
COMMENTS
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
LINKS
R. Zumkeller, Table of n, a(n) for n = 0..10000
FORMULA
n <= a(n) < 10n. - Charles R Greathouse IV, Aug 07 2024
EXAMPLE
a(19) = 91 because the digits of 19 being 1 and 9, arranged in decreasing order they are 9 and 1.
a(20) = 20 because the digits are already in decreasing order.
MAPLE
A004186 := proc(n)
local dgs;
convert(n, base, 10) ;
dgs := sort(%) ;
add( op(i, dgs)*10^(i-1), i=1..nops(dgs)) ;
end proc:
seq(A004186(n), n=0..20) ; # R. J. Mathar, Jul 26 2015
MATHEMATICA
sortDigitsDown[n_] := FromDigits@ Reverse@ Sort@ IntegerDigits@ n; Array[sortDigitsDown, 73, 0] (* Robert G. Wilson v, Aug 19 2011 *)
PROG
(PARI)
reconstruct(m) = {local(r); r=0; for(i=1, matsize(m)[2], r=r*10+m[i]); r}
A004186(n) = reconstruct(vecsort(digits(n), , 4))
\\ Michael B. Porter, Nov 11 2009
(PARI) a(n) = fromdigits(vecsort(digits(n), , 4)); \\ Joerg Arndt, Feb 24 2019
(Haskell)
import Data.List (sort)
a004186 = read . reverse . sort . show :: Integer -> Integer
-- Reinhard Zumkeller, Aug 19 2011
(Python)
def a(n): return int("".join(sorted(str(n), reverse=True)))
print([a(n) for n in range(73)]) # Michael S. Branicky, Feb 21 2021
CROSSREFS
KEYWORD
AUTHOR
EXTENSIONS
More terms from Reinhard Zumkeller, Oct 31 2007
STATUS
approved