OFFSET
1,2
COMMENTS
Minimal means minimize u^2+v^2. We follow Maple, PARI, etc., in setting u=0 and v=1 when x=y.
LINKS
Robert Israel, Table of n, a(n) for n = 1..2500
MAPLE
T:= proc(x, y) option remember; local g, u0, v0, t0, t1, t2;
g:= igcd(x, y);
if g > 1 then return procname(x/g, y/g) fi;
v0:= y^(-1) mod x;
u0:= (1-y*v0)/x;
t0:= (v0*x-u0*y)/(x^2+y^2);
t1:= floor(t0);
if t0 < t1 + 1/2 then u0+v0 + t1*(y-x)
else u0+v0 + (t1+1)*(y-x)
fi
end proc:
R:= 1: v:= 1:
for n from 2 to 100 do v:= v+1+2*add(T(i, n), i=1..n-1); R:= R, v od:
R; # Robert Israel, Mar 28 2023
MATHEMATICA
T[x_, y_] := T[x, y] = Module[{u, v}, MinimalBy[{u, v} /. Solve[u^2 + v^2 <= x^2 + y^2 && u*x + v*y == GCD[x, y], {u, v}, Integers], #.# &]];
a[n_] := a[n] = Sum[T[x, y][[1]]//Total, {x, 1, n}, {y, 1, n}];
Table[Print[n, " ", a[n]]; a[n], {n, 1, 54}] (* Jean-François Alcover, Mar 28 2023 *)
PROG
(Python)
from sympy.core.numbers import igcdex
def A345428(n): return sum(u+v for u, v, w in (igcdex(x, y) for x in range(1, n+1) for y in range(1, n+1))) # Chai Wah Wu, Jun 24 2021
CROSSREFS
KEYWORD
sign
AUTHOR
N. J. A. Sloane, Jun 22 2021
STATUS
approved