login
A361581
If n is composite, replace n with the concatenation of its nontrivial divisors, written in decreasing order, each divisor being written in base 10 with its digits in reverse order, otherwise a(n) = n.
0
1, 2, 3, 2, 5, 32, 7, 42, 3, 52, 11, 6432, 13, 72, 53, 842, 17, 9632, 19, 1542, 73, 112, 23, 2186432, 5, 312, 93, 41742, 29, 51016532, 31, 61842, 113, 712, 75, 812196432, 37, 912, 313, 2018542, 41, 12417632, 43, 221142, 51953, 322, 47, 42612186432, 7, 520152
OFFSET
1,2
EXAMPLE
Nontrivial divisors of 20 are 2,4,5,10, so a(20)=1542.
PROG
(PARI) a(n) = if (isprime(n) || (n==1), n, my(d=divisors(n)); my(s=""); forstep(k=#d-1, 2, -1, my(dk = digits(d[k])); for (i=1, #dk, s=concat(s, Str(dk[#dk-i+1])))); 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)[::-1] 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