A327987 a(n) = Sum_{d|n} d & (n/d), where & is the bitwise AND operator, with a(0) = 0.
0, 1, 0, 2, 2, 2, 4, 2, 0, 5, 0, 2, 4, 2, 4, 4, 4, 2, 4, 2, 12, 8, 4, 2, 8, 7, 0, 4, 12, 2, 16, 2, 0, 8, 0, 12, 10, 2, 4, 4, 0, 2, 16, 2, 4, 10, 4, 2, 8, 9, 0, 4, 12, 2, 8, 4, 8, 8, 0, 2, 24, 2, 4, 6, 8, 12, 8, 2, 4, 8, 16, 2, 24, 2, 0, 14, 4, 8, 16, 2, 24, 17
Offset: 0
Keywords
Links
- Antti Karttunen, Table of n, a(n) for n = 0..16384
Programs
-
Julia
using IntegerSequences vcat([0], [V327987(n) for n in 1:81]) |> println # Peter Luschny, Sep 25 2021
-
Magma
[0] cat [&+[BitwiseAnd(d,n div d):d in Divisors(n)]:n in [1..90]]; // Marius A. Burtea, Oct 11 2019
-
Maple
A327987 := n -> add(Bits:-And(d, n/d), d=numtheory:-divisors(n)): seq(A327987(n), n=0..81);
-
Mathematica
divisors[0] := {}; divisors[n_] := Divisors[n]; a[n_] := Total[Table[BitAnd[d , n/d], {d, divisors[n]}]] ; Table[a[n], {n, 0, 81}]
-
PARI
a(n) = if (n, sumdiv(n, d, bitand(d, n/d)), 0); \\ Michel Marcus, Oct 11 2019
-
Sage
def a(n): return sum(d & n//d for d in divisors(n)) if n > 0 else 0 print([a(n) for n in (0..81)])
Formula
a(n) is odd if and only if n is an odd square (A016754).
Comments