OFFSET
1,3
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..20000
Antti Karttunen, Data supplement: n, a(n) computed for n = 1..100000
MATHEMATICA
a[n_] := Module[{m = 1}, While[!Divisible[m*(m + 1), n], m++]; GCD[n, m + 1] - GCD[n, m]]; Array[a, 100] (* Amiram Eldar, Jun 16 2022 *)
PROG
(PARI) A354988(n) = for(m=1, oo, if((m*(m+1))%n==0, return(gcd(n, 1+m)-gcd(n, m))));
(Python 3.8+)
from math import gcd, prod
from itertools import combinations
from sympy import factorint
from sympy.ntheory.modular import crt
def A354988(n):
if n == 1:
return 0
plist = tuple(p**q for p, q in factorint(n).items())
return n-1 if len(plist) == 1 else -gcd(n, s:=int(min(min(crt((m, n//m), (0, -1))[0], crt((n//m, m), (0, -1))[0]) for m in (prod(d) for l in range(1, len(plist)//2+1) for d in combinations(plist, l))))) + gcd(n, s+1) # Chai Wah Wu, Jun 16 2022
CROSSREFS
KEYWORD
sign
AUTHOR
Antti Karttunen, Jun 16 2022
STATUS
approved