OFFSET
1,1
LINKS
Kevin Long, Table of n, a(n) for n = 1..10000
Kevin Long, Python code for sequence
FORMULA
PROG
(PARI) a(n) = {my(s=1, k=2); while(s%n, s+=k; k++); k} \\ Andrew Howroyd, Aug 27 2019
(Python 3.8+)
from itertools import combinations
from math import prod
from sympy import factorint, divisors
from sympy.ntheory.modular import crt
def A321366(n):
plist = [p**q for p, q in factorint(2*n).items()]
if len(plist) == 1:
return int((2 - plist[0] % 2)*n)
return 1+int(min(min(crt([m, 2*n//m], [0, -1])[0], crt([2*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)))) # Chai Wah Wu, Jun 03 2021
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Kevin Long, Aug 27 2019
STATUS
approved