OFFSET
1,2
LINKS
Yifan Xie, Table of n, a(n) for n = 1..146
Art of Problem Solving, Serbia National Math Olympiad 2026 Problem 1
Yifan Xie, Python program
Yifan Xie, Proof of the formulas
FORMULA
If n <= 2, a(n) = n;
If n > 2 is squarefree, a(n) = n - 1;
If p^2 divides n, where p is a prime, a(n) <= n*(2*p^2 - p + 1)/(2*p^2).
EXAMPLE
For n = 6, one permutation that realizes the maximum value is 1, 2, 3, 6, 4, 5. There are 5 distinct residues mod 6 among {1*1, 2*2, 3*3, 4*6, 5*4, 6*5}. Hence a(6) = 5.
For n = p, where p is an odd prime, one permutation f that realizes the maximum value is f(x) = 1 + x^(-1) for 1 <= x <= p-2, f(p-1) = p and f(p) = 1, where x^(-1) is the inverse of x modulo p.
CROSSREFS
KEYWORD
nonn,new
AUTHOR
Yifan Xie, Jun 16 2026
STATUS
approved
