OFFSET
1,2
COMMENTS
The number of these integers is phi(2*n) = A062570(n).
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = Sum_{k=1..n, gcd(k,n) is power of 2} k = Sum_{k=1..n} A209229(gcd(k,n)) * k.
a(n) = A007582(e) = 2^(e-1)*(2^e+1) if n = 2^e is a power of 2 (A000079), and a(n) = phi(2*n)*n/2 otherwise.
a(n) >= A023896(n), with equality if and only if n is odd.
a(n) <= n*(n+1)/2, with equality if and only if n is a power of 2.
Dirichlet g.f.: (zeta(s-2)/zeta(s-1) + 1) / (2 - 1/2^(s-2)).
Sum_{k=1..n} a(k) ~ (4/(3*Pi^2)) * n^3.
MATHEMATICA
a[n_] := Module[{e = IntegerExponent[n, 2]}, If[n == 2^e, 2^(e-1)*(2^e+1), EulerPhi[2*n]*n/2]]; Array[a, 100]
PROG
(PARI) a(n) = {my(e = valuation(n, 2)); if(n >> e == 1, 2^(e-1)*(2^e+1), eulerphi(2*n)*n/2); }
(Python)
from sympy import totient
def A390804(n): return totient(n<<1)*n>>1 if (n&-n)^n else n*(n+1)>>1 # Chai Wah Wu, Mar 14 2026
CROSSREFS
The sum of the integers k from 1 to n such that gcd(n, k) is: A023896 (1), A119790 (prime power, A246655), A390800 (power of prime, A000961), A390801 (prime), A390802 (odd), A390803 (5-rough), this sequence (power of 2), A390805 (3-smooth), A390806 (squarefree), A390807 (cubefree), A390808 (square), A390809 (1 or 2).
KEYWORD
nonn,easy
AUTHOR
Amiram Eldar, Nov 20 2025
STATUS
approved
