login
A345425
For 1<=x<=n, 1<=y<=n, with gcd(x,y)=1, write 1 = gcd(x,y) = u*x+v*y with u,v minimal; a(n) = sum of the values of u+v.
3
1, 3, 5, 7, 9, 11, 11, 15, 13, 13, 15, 19, 5, 15, 11, 7, 11, 5, -13, 3, -17, -15, -7, 9, -49, -49, -51, -79, -61, -37, -61, -33, -105, -129, -113, -141, -183, -141, -157, -181, -189, -169, -275, -175, -199, -229, -217, -249, -389, -429, -413, -381, -419, -425, -453, -397
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.
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 == 1, {u, v}, Integers], #.# &]];
a[n_] := a[n] = Sum[If[GCD[x, y] == 1, T[x, y][[1]] // Total, 0], {x, 1, n}, {y, 1, n}];
Table[Print[n, " ", a[n]]; a[n], {n, 1, 56}] (* Jean-François Alcover, Mar 28 2023 *)
PROG
(Python)
from sympy.core.numbers import igcdex
def A345425(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)) if w == 1) # Chai Wah Wu, Jun 24 2021
CROSSREFS
KEYWORD
sign
AUTHOR
N. J. A. Sloane, Jun 22 2021
STATUS
approved