OFFSET
1,2
COMMENTS
Any leading zeros of a rearrangement are discarded.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
a(153) = 531 since the digits of 153 can be rearranged to 135,315,351,513 and 531; and 531 has the largest prime factor of the set (59).
MATHEMATICA
A390052[n_] := Last[SortBy[Map[FromDigits, Permutations[IntegerDigits[n]]], FactorInteger[#][[-1, 1]] &, Less]];
Array[A390052, 100] (* Paolo Xausa, Oct 31 2025 *)
PROG
(Python)
from sympy import factorint
from itertools import permutations
def a(n):
if n == 1: return 1
m, argm = 0, None
for p in permutations(sorted(str(n))):
t = int("".join(p))
f = 0 if t == 1 else max(factorint(t))
if f > m: m, argm = f, t
return argm
print([a(n) for n in range(1, 70)])
(PARI) gpf(n) = if (n==1, 1, vecmax(factor(n)[, 1]));
a(n) = my(d = digits(n), vi = vecsort(vector((#d)!, i, my(p = numtoperm(#d, i-1)); fromdigits(vector(#d, k, d[p[k]])))), vg = apply(gpf, vi), vmax = vecmax(vg), vs = select(x->(x==vmax), vg, 1)); vi[vs[1]]; \\ Michel Marcus, Oct 24 2025
CROSSREFS
KEYWORD
AUTHOR
Michael S. Branicky and Ali Sada, Oct 22 2025
STATUS
approved
