OFFSET
1,4
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)
A325967aux(n, ds, s, ms, divs, from=1) = if(1==gcd((s-ds)-n, n-ds), return(ds), for(i=from, #divs, if(ds+divs[i] >= ms, return(ms), ms = min(ms, A325967aux(n, ds+divs[i], s, ms, divs, i+1)))); (ms));
A325967(n) = if(1==gcd(n, sigma(n)), 0, my(divs = List(divisors(n)), s=sigma(n), ms=2*s); fordiv(n, d, if(d>=ms, return(ms), listpop(divs, 1); ms = min(ms, A325967aux(n, d, s, ms, divs)))); (ms));
(PARI)
A325968(n) = { my(divs=divisors(n), s=sigma(n), r, ms=0); for(b=0, (2^(length(divs)))-1, r=sumbybits(divs, b); if(1==gcd(n-(s-r), n-r), ms=max(r, ms))); (ms); };
sumbybits(v, b) = { my(s=0, i=1); while(b>0, s += (b%2)*v[i]; i++; b >>= 1); (s); };
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, May 29 2019
STATUS
approved