OFFSET
1,3
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..16384
Antti Karttunen, Data supplement: n, a(n) computed for n = 1..65537
FORMULA
PROG
(PARI)
A005187(n) = { my(s=n); while(n>>=1, s+=n); s; };
A011772(n) = { if(n==1, return(1)); my(f=factor(if(n%2, n, 2*n)), step=vecmax(vector(#f~, i, f[i, 1]^f[i, 2]))); forstep(m=step, 2*n, step, if(m*(m-1)/2%n==0, return(m-1)); if(m*(m+1)/2%n==0, return(m))); }; \\ From A011772
(Python 3.8+)
from itertools import combinations
from math import prod
from sympy import factorint, divisors
from sympy.ntheory.modular import crt
def A344769(n):
c = 2*n-bin(n).count('1')
plist = [p**q for p, q in factorint(2*n).items()]
if len(plist) == 1:
return int(c+1+(plist[0] % 2 - 2)*n)
return int(c-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
AUTHOR
Antti Karttunen, May 30 2021
STATUS
approved