login
A390599
Smallest number obtained by concatenating a permutation of the divisors of n.
1
1, 12, 13, 124, 15, 1236, 17, 1248, 139, 10125, 111, 1122346, 113, 11427, 11535, 116248, 117, 1182369, 119, 10120245, 12137, 111222, 123, 1122243468, 1255, 113226, 12739, 11422847, 129, 10115230356, 131, 11623248, 111333, 117234, 13557, 112182336469, 137, 119238
OFFSET
1,2
LINKS
Edvard Davtyan and Lewin Gan, 632C - The Smallest String Concatenation, Tutorial, Educational Codeforces Round 9.
MATHEMATICA
a[n_]:=Min[FromDigits/@Flatten/@IntegerDigits/@Permutations[Divisors[n]]]; Array[a, 38] (* James C. McMahon, Nov 13 2025 *)
PROG
(PARI) a(n) = {my(d=apply(x->Str(x), divisors(n)), d2=vecsort(d, (x, y)->cmp(concat(x, y), concat(y, x)))); eval(concat(d2))}
(Python)
from sympy import divisors
from functools import cmp_to_key
def c(x, y): return -1 if x+y < y+x else int(x+y > y+x)
def a(n): return int("".join(sorted(list(map(str, divisors(n))), key=cmp_to_key(c))))
print([a(n) for n in range(1, 39)]) # Michael S. Branicky, Nov 12 2025
CROSSREFS
Sequence in context: A135123 A129476 A243361 * A037278 A164852 A362113
KEYWORD
nonn,base,easy
AUTHOR
Jason Yuen, Nov 12 2025
STATUS
approved