login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A345428
For 1<=x<=n, 1<=y<=n, write gcd(x,y) = u*x+v*y with u,v minimal; a(n) = sum of the values of u+v.
7
1, 4, 7, 12, 15, 22, 23, 32, 33, 38, 41, 54, 41, 54, 55, 60, 65, 64, 47, 70, 53, 60, 69, 102, 47, 36, 35, 22, 41, 70, 47, 80, 13, -4, 15, -8, -49, -22, -49, -46, -53, -36, -141, -32, -57, -76, -63, -66, -205, -298, -275, -252, -289, -298
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
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