OFFSET
1,2
LINKS
Michael De Vlieger, Table of n, a(n) for n = 1..10000
EXAMPLE
Nontrivial divisors of 20 are 2,4,5,10, so a(20)=10542.
MAPLE
f:= proc(n) local L;
if isprime(n) then return n fi;
L:= sort(convert(numtheory:-divisors(n) minus {1, n}, list), `>`);
parse(cat(op(L)))
end proc:
f(1):= 1:
map(f, [$1..100]); # Robert Israel, Mar 16 2023
MATHEMATICA
Array[If[CompositeQ[#], FromDigits@ Flatten@ Map[IntegerDigits, Reverse@ Divisors[#][[2 ;; -2]] ], #] &, 50] (* Michael De Vlieger, Mar 22 2023 *)
PROG
(PARI) a(n) = if (isprime(n) || (n==1), n, my(d=divisors(n)); my(s=""); for(k=2, #d-1, s=concat(Str(d[k]), s)); eval(s)); \\ Michel Marcus, Mar 16 2023
(Python)
from sympy import divisors, isprime
def a(n):
if n == 1 or isprime(n): return n
return int("".join(str(d) for d in divisors(n)[-2:0:-1]))
print([a(n) for n in range(1, 51)]) # Michael S. Branicky, Mar 21 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Tyler Busby, Mar 16 2023
STATUS
approved